cse 205 wi 2012 – intro & chapter 1
TRANSCRIPT
Course Objectives • Skills for Computational thinking. • Master basic constructs provided by high-level imperative programming languages • Be knowledgeable of concepts including sequencing, selection, and iteration • Gain exposure to algorithmic thinking • Be aware of computational approaches to solving problems • Be familiar with basic data structures such as arrays and procedural composition • Gain exposure to computational methods of simulation/optimization/data analysis. • Be knowledgeable of computational complexity and performance issues.
Course Logistics • Instructor:
– Raghu Machiraju, – Office: DL779 – Email: [email protected] – Phone: 1-614-292-6730
• Class – Lecture - TR: 09:00AM-10:18AM DL0305 – OpenLab - F: 08:30AM-09:18AM BE
• Instructor Office Hours@DL779 – TR: 8 - 8:45 AM, 10:30-11:00 AM – F: 9:30-10:00 AM
Logistics(2) • Grader
– Do Young Park – Office: DLXXX – Email: [email protected] – Phone: 1-614-XXX-YYY
• Grader Office Hours@DLxx TBA
Logisitics(3) • Final Exam
– Mon, March 12, 7:30 AM - 9:18 AM
• Course Webpage with all details: http://www.cse.ohio-state.edu/~raghu/teaching/cse205wi2012
• Content will be incrementally posted on Carmen
• Home works : Posted on most Thursdays – Due by next Wednesday midnight- Submit
electronic copy on Carmen.
– Submit hard copy next Thursday class.
Course Grading
Chapter 1: Outline – 1.1 Computation as a transformation
– 1.2 Computation as a reaction to events
– “State” and change of “state”
– 1.3 Algorithms
Reading Assignment: Chapter 1
1.1 Computation as Transformation
– Input = x; Output =√x
http://www.macalester.edu/~kaplan/scientificprogramming/figures.ppt
– Input = financial info; Output = tax owed OR refund
http://www.macalester.edu/~kaplan/scientificprogramming/figures.ppt
Example: Computation as Transformation
– Input = image file; Output = “This is the Mona Lisa!”
http://www.macalester.edu/~kaplan/scientificprogramming/figures.ppt
Example: Computation as Transformation
1.2 Computation as Reaction to Events
• Inputs often come from measurements • Measurements are typically performed
using transducers (convert input signal into numbers) – microphone – speedometer – thermometer – seismograph – radar
Example: Computation as Reaction
http://research.utk.edu/ora/explore/sundial.jpg
– Sundial (and compass): Analog transducers
The operation of sixteenth-century sundial. By aligning the sight holes with the sun, the string transduces the altitude of the sun onto a set of several scales that indicate the time of day. The appropriate scale is picked based on the day of the year.
– Because measurements (signals) typically change over time, we get the concept of state : the set of values describing a system at a given time
– E.g. • Health: <blood pressure, temperature, heart rate> • Airplane: <heading, altitude, fuel> • Subatomic particle: <position, momentum>
– An important model of computation • A computation as a transition from an old
state to a new state.
Computation as Reaction to Events
1.3 Algorithm ● A step-by-step specification of “basic” transformations
● Recipe analogy: How to make a cake? 1. Mix ½ cup lard, ½ cup butter, getting them good and creamy. 2. Mix in 1 cup flour, ¾ cup brown sugar, ¾ cup white sugar, 2 eggs, 1 tsp. vanilla, and ½ tsp. baking soda. 3. Work this over until it is thoroughly mixed, then blend in 1 ¼ cup more flour. 4. Bake at 375 degrees 8-10 minutes.
• Illustrates three key aspects of algorithms: • Sequencing of steps • Repetition • Conditional execution (perform if some test condition holds)
Multi-digit Addition Several snapshots of the
paper-and-pencil algorithm for adding two multidigit numbers.
Example of Algorithm: Compare Numbers
• Compare two Arabic numerals (e.g., 23 and 97) to determine which is larger 1. Count the digits in each numeral. If one has
more digits than another, the one with more is the larger.
2. Otherwise, compare the leftmost digits in the two numerals. If one digit is larger than the other, the numeral with the larger leftmost digit is the larger numeral.
3. Otherwise, chop off the first numeral and go to step 2.
Example: Find Smallest
• Example: Find smallest number in list 1. Assume smallest is first item in list. 2. If there are no more items in list, we're
done. Report smallest number. 3. Otherwise, look at next item. If it's smaller
than current assumed “smallest” value, make current answer equal to value of this item.
4. Go to step 2.
Example: Find Smallest
LIST: 5 2 9 1 3
LIST: 5 2 9 1 3
SMALLEST-SO-FAR: 5
LIST: 5 2 9 1 3
SMALLEST-SO-FAR: 2
LIST: 5 2 9 1 3
SMALLEST-SO-FAR: 2
LIST: 5 2 9 1 3
SMALLEST-SO-FAR: 1
LIST: 5 2 9 1 3
SMALLEST-SO-FAR: 1
LIST: 5 2 9 1 3
SMALLEST: 1
Advanced Example: Sorting a List
• Example: Sort a list of numbers 1. Create a new, empty list 2. Find the smallest item in the old list. 3. Remove this item from the old list and add it
to the beginning of the new list. 4. If the old list is empty, we're done. Output
the new list. 5. Otherwise, go to step 2.
Example: Sorting a List OLD: 5 2 9 1 3 NEW:
NEW: OLD: 5 2 9 1 3
OLD: 5 2 9 3 NEW: 1 OLD: 5 2 9 3 NEW: 1
OLD: 5 9 3 NEW: 1 2
OLD: 5 9 3 NEW: 1 2
OLD: 5 9 NEW: 1 2 3
OLD: 5 9 NEW: 1 2 3 OLD: 9 NEW: 1 2 3 5
OLD: NEW: 1 2 3 5 9
Algorithms to software
• Solving equations • Searching through data for matches • Finding maxima and minima • Simulating random processes
Elements of Software
• Representations – Lists (Searching, Sorting) – Object Assemblies (Bridge)
• Modules and Modularity • Visualization • Enforce engineering discipline