Top Banner
CSE 205 Wi 2012 – Intro & Chapter 1
44

CSE 205 Wi 2012 – Intro & Chapter 1

Mar 15, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSE 205 Wi 2012 – Intro & Chapter 1

CSE 205 Wi 2012 – Intro & Chapter 1

Page 2: CSE 205 Wi 2012 – Intro & Chapter 1

Acknowledgments 1.  Prof. P. Sadayappan, CSE 2.  Prof. D. Kaplan (Author of Text)

Page 3: CSE 205 Wi 2012 – Intro & Chapter 1

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.

Page 4: CSE 205 Wi 2012 – Intro & Chapter 1

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

Page 5: CSE 205 Wi 2012 – Intro & Chapter 1

Logistics(2) •  Grader

–  Do Young Park –  Office: DLXXX –  Email: [email protected] –  Phone: 1-614-XXX-YYY

•  Grader Office Hours@DLxx TBA

Page 6: CSE 205 Wi 2012 – Intro & Chapter 1

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

Page 7: CSE 205 Wi 2012 – Intro & Chapter 1

Course Grading

•  Assignments: 50% (10 x 5)

•  Midterm: 20%

•  Final Exam: 30%

Page 8: CSE 205 Wi 2012 – Intro & Chapter 1

•  Home works : Posted on most Thursdays –  Due by next Wednesday midnight- Submit

electronic copy on Carmen.

– Submit hard copy next Thursday class.

Course Grading

Page 9: CSE 205 Wi 2012 – Intro & Chapter 1

What is Computation?

Page 10: CSE 205 Wi 2012 – Intro & Chapter 1

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

Page 11: CSE 205 Wi 2012 – Intro & Chapter 1

1.1 Computation as Transformation

– Input = x; Output =√x

http://www.macalester.edu/~kaplan/scientificprogramming/figures.ppt

Page 12: CSE 205 Wi 2012 – Intro & Chapter 1

–  Input = financial info; Output = tax owed OR refund

http://www.macalester.edu/~kaplan/scientificprogramming/figures.ppt

Example: Computation as Transformation

Page 13: CSE 205 Wi 2012 – Intro & Chapter 1

– Input = image file; Output = “This is the Mona Lisa!”

http://www.macalester.edu/~kaplan/scientificprogramming/figures.ppt

Example: Computation as Transformation

Page 14: CSE 205 Wi 2012 – Intro & Chapter 1

Example: Computation as Transformation

EE

OH

Speech sounds as recorded by a microphone.

Page 15: CSE 205 Wi 2012 – Intro & Chapter 1

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

Page 16: CSE 205 Wi 2012 – Intro & Chapter 1

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.

Page 17: CSE 205 Wi 2012 – Intro & Chapter 1

Example: Computation as Reaction

A transducer from temperature to position

Page 18: CSE 205 Wi 2012 – Intro & Chapter 1

– 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

Page 19: CSE 205 Wi 2012 – Intro & Chapter 1
Page 20: CSE 205 Wi 2012 – Intro & Chapter 1

A Turing Machine (abstract)

Page 21: CSE 205 Wi 2012 – Intro & Chapter 1

A Computer

Page 22: CSE 205 Wi 2012 – Intro & Chapter 1

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)

Page 23: CSE 205 Wi 2012 – Intro & Chapter 1

Multi-digit Addition Several snapshots of the

paper-and-pencil algorithm for adding two multidigit numbers.

Page 24: CSE 205 Wi 2012 – Intro & Chapter 1

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.

Page 25: CSE 205 Wi 2012 – Intro & Chapter 1

Example: Addition of 3 Numbers

Page 26: CSE 205 Wi 2012 – Intro & Chapter 1

Flow Charts

?

Page 27: CSE 205 Wi 2012 – Intro & Chapter 1

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.

Page 28: CSE 205 Wi 2012 – Intro & Chapter 1

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

Page 29: CSE 205 Wi 2012 – Intro & Chapter 1

Algorithm: Find Smallest

The Flow Chart ?

Page 30: CSE 205 Wi 2012 – Intro & Chapter 1

Stepping Through Algorithm

Page 31: CSE 205 Wi 2012 – Intro & Chapter 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.

Page 32: CSE 205 Wi 2012 – Intro & Chapter 1

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

Page 33: CSE 205 Wi 2012 – Intro & Chapter 1

Algorithm: Sorting a List

The Flow Chart ?

Page 34: CSE 205 Wi 2012 – Intro & Chapter 1

Stepping Through Algorithm

Page 35: CSE 205 Wi 2012 – Intro & Chapter 1

What is next ?

•  Build Software ? •  Which platform ? •  Let us name some …

Page 36: CSE 205 Wi 2012 – Intro & Chapter 1

Algorithms to software

•  Solving equations •  Searching through data for matches •  Finding maxima and minima •  Simulating random processes

Page 37: CSE 205 Wi 2012 – Intro & Chapter 1

Elements of Software

•  Representations – Lists (Searching, Sorting) – Object Assemblies (Bridge)

•  Modules and Modularity •  Visualization •  Enforce engineering discipline

Page 38: CSE 205 Wi 2012 – Intro & Chapter 1

Visualization

Page 39: CSE 205 Wi 2012 – Intro & Chapter 1

Nomograms

Page 40: CSE 205 Wi 2012 – Intro & Chapter 1

Nomogram (2)

Page 41: CSE 205 Wi 2012 – Intro & Chapter 1

More Visualization

Page 42: CSE 205 Wi 2012 – Intro & Chapter 1

Visualization(2)

Page 43: CSE 205 Wi 2012 – Intro & Chapter 1

Visualization(3)

Page 44: CSE 205 Wi 2012 – Intro & Chapter 1

Recap