

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Introduction to Computing Using MATLAB; Subject: Computer Science; University: Cornell University; Term: Fall 2008;
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Previous Lecture: Iteration using while
Today’s Lecture: Developing algorithms Nested loops
Announcements: Project 2 due 9/22 (Mon) at 6pm Prelim 1 on 9/25 (Thurs) 7:30pm. If you have a conflict, tell us (email Kelly Patwell) now—no later than tomorrow. You’ll use your clicker for a quiz soon—register it!
Draw a black square
Draw a sequence of stars -Stars get smaller -Stars alternate in color -1 st^ star smaller than the sqr -radius r=1 to start -When to stop?
September 18, 2008 Lecture 7 9
September 18, 2008 Lecture 7 19
Row headings
Column headings
September 18, 2008 Lecture 7 23
Here's the biggest rectangle you drew!
September 18, 2008 Lecture 7 26
A mode is the number in a sequence that appears the most number of times Develop an algorithm for calculating the mode of a user- entered sequence that is Non-negative Entered one-by-one in non-decreasing order Terminated by a negative number E.g., sequence 87, 92, 92, 98, 98, 98, 100 has a mode… Write the algorithm and then the code on your own for practice!
September 18, 2008 Lecture 7 28
Learns useful programming patterns and use them where appropriate Seeks inspiration by working through test data “by hand” Asks, “What am I doing?” at each step Declares a variable for each piece of information maintained when working the problem by hand Decomposes the problem into manageable subtasks Refines the solution iteratively, solving simpler subproblems first Remembers to check the problem’s boundary conditions Validates the solution (program) by trying it on test data