We aren't endorsed by this school

CS 1109 - Fundamental Programming - Cornell Study Resources
  • 1 Page lab5-sol
    Lab5-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 5 Solutions July 12 Introduction to Arrays Creating a Vector The command linspace(a,b,n) produces an array that begins with the number a, ends with the number b, and contains n elements, which are equally spaced from each other and

  • 1 Page lab9-sol
    Lab9-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 9 Solutions July 26 Functions Revisited On the surface, there doesnt appear to be much dierent between a script that takes no inputs and produces no outputs, and a function that takes no inputs and produces no outputs. However, rec

  • 3 Pages quiz4-sol
    Quiz4-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Quiz 4 Solutions July 21 Name: NetID: You have 10 minutes to complete this quiz. You may not use a computer to answer the questions. 1. What is a nested loop? [Ans] A nested loop is a structure where one or more loops are placed inside

  • 1 Page lab7-sol
    Lab7-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 7 Solutions July 19 Nested Loops The outer loop (with index i) runs a total of 20 times. For each run of the outer loop, the inner loop (with index j ) runs 10 times. Thus, in total, the body of the nested loop runs 20 10 = 200 tim

  • 3 Pages lab7
    Lab7

    School: Cornell

    Course: Fundamental Programming

    Lab 7 CS 1109 Summer 2011 July 19 In this lab, you will develop programs that use single and nested loops. General Lab Instructions This lab is designed to be completed within the scheduled class meeting time. There are three deliverables for this lab a W

  • 2 Pages quiz3-sol
    Quiz3-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Quiz 3 Solutions July 14 Name: NetID: You have 10 minutes to complete this quiz. You may not use a computer to answer the questions. 1. What is a vector? [Ans] A vector, or a one-dimensional array, is a collection of data organized in

  • 1 Page lab6-sol
    Lab6-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 6 Solutions July 14 Practice Using the Colon Operator Useful Functions: zeros and ones 1. To generate a vector of length 10 lled with zeros: zeros(1,10) 2. To generate a 4 6 matrix lled with 10s: 10*ones(4,6) Reversing Arrays To re

  • 4 Pages lab6
    Lab6

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 6 July 14 In this lab, you will get a chance to work with the colon notation and matrices (two-dimensional arrays). You will also be introduced to the for-loop construct. General Lab Instructions This lab is designed to be complete

  • 4 Pages hw1_sol
    Hw1_sol

    School: Cornell

    Course: Fundamental Programming Concepts

    CS 1109 1 1.a Homework 1 - Solution July 8, 2013 Spherical Triangle Area and Excess In this part all you have to do is to transfer the given mathematical formulas into assignments using arithmetic operators in MATLAB. When you run the script le, test tria

  • 5 Pages hw2_sol
    Hw2_sol

    School: Cornell

    Course: Fundamental Programming Concepts

    CS 1109 1 Homework 2 - Solution July 16, 2013 Mind the gap function p = prime gap(n,d) % Returns the prime numbers separated by a gap d and smaller than n. % p is an array which contains pairs of primes in order. x = primes(n); m = length(x) 1; p = []; %

  • 9 Pages hw3_sol
    Hw3_sol

    School: Cornell

    Course: Fundamental Programming Concepts

    Homework 3 - Solutions CS 1109 1 1.a July 29, 2013 Chess Initialization Initialization can be written as a simple assignment. function board = initialize() % Returns an initialized chessboard board = [ 8 7 0 0 0 0 1 2 1.b 9 10 11 12 10 77777 00000 00000 0

  • 5 Pages hw4_sol
    Hw4_sol

    School: Cornell

    Course: Fundamental Programming Concepts

    CS 1109 1 1.1 Homework 4 - Solution August 6, 2012 Sound Eects Delay function result = delay(data, fs, delta) % Delays the sound stored in data by an amount delta given in seconds. % Each data point is seperated by 1/fs seconds. dn = floor(delta * fs); re

  • 2 Pages quiz5-sol
    Quiz5-sol

    School: Cornell

    Course: Fundamental Programming Concepts

    CS 1109 Summer 2011 Quiz 5 Solutions July 28 Name: NetID: You have 10 minutes to complete this quiz. You may not use a computer to answer the questions. 1. What are the two main dierences between Matlab functions and scripts? [Ans] (a) A Matlab function c

  • 1 Page qz1a
    Qz1a

    School: Cornell

    Course: Fundamental Programming Concepts

    Quiz 1 CS 1109 1 Assignment x y z x y = = = = = Date: June 26, 2013 (5 points) 6; 3; x / y; x - y; z + 2 * x; What are the nal values for x: 2 y: z: MATLAB functions (5 points) phi = 2*pi; theta = phi/2; st = sin(theta); val = exp(st); % theta = 2*theta;

  • 2 Pages qz2a
    Qz2a

    School: Cornell

    Course: Fundamental Programming Concepts

    QUIZ 2 Name:_ netID:_ Tick the correct output. Some questions have been marked as Multiple choice, the rest have one correct answer. 1. i = 1; while (i < 10) i=i+1 end A. Numbers from 2 to 10 C. No output B. Numbers from 1 to 10 D. Numbers from 1 to 11 2.

  • 5 Pages lab9
    Lab9

    School: Cornell

    Course: Fundamental Programming

    Lab 9 CS 1109 Summer 2011 July 26 In this lab, you will gain an appreciation for Matlabs usefulness as a data visualization tool. You will also learn how to plot 2-D curves and format gures. General Lab Instructions This lab is designed to be completed wi

  • 5 Pages lab10
    Lab10

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 10 July 28 In this lab, you will learn the basics of image processing in Matlab and implement a couple of simple ltering routines. General Lab Instructions This lab is designed to be completed within the scheduled class meeting tim

  • 1 Page lab10-sol
    Lab10-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 10 Solutions July 28 Negative of an Image Comparing the Two Approaches The exact speed-up factor depends on the specic computer you run your code on, as well as whether you included the time taken to render the image negative (i.e.

  • 6 Pages lab5
    Lab5

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 5 July 12 In this lab, you will learn about one of the most fundamental data structures in computer science the array. You will learn how to create and manipulate arrays in Matlab. General Lab Instructions This lab is designed to b

  • 2 Pages quiz2-sol
    Quiz2-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Quiz 2 Solutions July 7 Name: NetID: You have 10 minutes to complete this quiz. You may not use a computer to answer the questions. 1. What is an innite loop? [Ans] An innite loop is one that causes a set of instructions or statements

  • 5 Pages lab3
    Lab3

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 3 July 5 In this lab, you will learn about the fundamental branching construct, the ifstatement. General Lab Instructions This lab is designed to be completed within the scheduled class meeting time. There are three deliverables fo

  • 1 Page lab3-sol
    Lab3-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 3 Solutions July 5 The if-else-statement if (expression) Statement a1 ; Statement a2 ; . . . else Statement b1 ; Statement b2 ; . . . end To execute the above conditional statement, we begin by evaluating expression. If expression

  • 2 Pages quiz1-sol
    Quiz1-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Quiz 1 Solutions June 30 Name: NetID: You have 10 minutes to complete this quiz. You may not use a computer to answer the questions. 1. In a step-by-step fashion, describe how an assignment statement of the form variable name = express

  • 1 Page lab2-sol
    Lab2-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 2 Solutions July 1 Obtaining User Input The \n is an escape character that introduces a newline into a string. Strings To prompt a user for string input, we supply a second argument to the input command that is simply s. For exampl

  • 5 Pages lab2
    Lab2

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 2 June 30 In this lab, you will learn how to solicit input from a user and print output to the screen in Matlab. You will also learn how to create simple Matlab scripts. General Lab Instructions This lab is designed to be completed

  • 2 Pages lab1-sol
    Lab1-sol

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 1 Solutions June 28 Matlab Starting Matlab How to start Matlab: In the CIT public Windows labs, Matlab can be started by selecting Start All Programs Class Files MATLAB R2010a MATLAB R2010a. Anatomy of the Matlab Environment Purpo

  • 3 Pages lab1
    Lab1

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Lab 1 June 28 In this lab, you will be introduced to Matlab (short for MATrix LABoratory ). You will also learn about two of the most fundamental building blocks of computer programs variables and assignment statements. General Lab Ins

  • 3 Pages lab8
    Lab8

    School: Cornell

    Course: Fundamental Programming

    Lab 8 CS 1109 Summer 2011 July 21 In this lab, you will learn more about how function calls are executed and practice writing functions of your own. General Lab Instructions This lab is designed to be completed within the scheduled class meeting time. The

  • 1 Page loops-review
    Loops-review

    School: Cornell

    Course: Fundamental Programming

    Review CS 1109 Summer 2011 July 11 Random Triangles Write a script named triangle.m that generates three random numbers a, b and c between 0 and 1. If a triangle can be formed with those side lengths, your script should print Triangle possible. Otherwise,

  • 3 Pages standards
    Standards

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Code Standards Documentation Script Headers Every script should be prefaced with a header that provides a high-level overview of the problem that it solves. Describe any assumptions that your script requires for correct behavior. For example, if t

  • 4 Pages hw2
    Hw2

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Homework 2 Due: July 11, 11:59PM Instructions The purpose of this assignment is to help you gain experience in writing scripts that make use of branching and looping constructs. Remember: You are allowed to discuss the homework with ot

  • 2 Pages hw0
    Hw0

    School: Cornell

    Course: Fundamental Programming

    CS 1109 Summer 2011 Homework 0 Due: June 28, 10:00AM The purpose of this assignment is to introduce you to the Computer Science departments Course Management System (CMS). You will be using this portal over the course of the summer to submit your homework

  • 1 Page qz3
    Qz3

    School: Cornell

    Course: Fundamental Programming Concepts

    1 Sorting (100 points) The following code sorts an array using an algorithm called bubblesort. function x = bubblesort(x) disp(= INPUT ARRAY =) fprintf(Array x) ); disp(x) disp(=) n = length(x); step = 0; for i=1:n-1 for j=1:n-i if x(j) > x(j+1) temp = x(

Back to course listings