Lecture03_prepost

# Lecture03_prepost - Lecture03 Algorithms and Callers...

This preview shows pages 1–14. Sign up to view the full content.

Engineering 101 Engineering 101 Lecture03 Lecture03 Algorithms and Callers Algorithms and Callers Prof. Michael Falk University of Michigan, College of Engineering

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Announcements Announcements Project 0 Due this Wednesday at 9pm Project0 directory will be generated for you by today. Make sure to name your program Project0.cpp with a capital “ P ”. You should have read Chapter 1 last week and be starting Chapter 2 this week (see Syllabus on website). Don’t worry if everything isn’t clear right away. Please correct me and question me during lecture! It helps me prevent dissemination of errors and helps your colleagues learn.
Every algorithm has a caller Every algorithm has a caller An algorithm is usually called by another algorithm. Caller Algorithm A

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Data is exchanged between the Data is exchanged between the algorithm and its caller algorithm and its caller Since our definition of an algorithm is that it transforms input to output there must be a way to accept input and provide output to the caller Caller Algorithm A Data Data Data
Example Algorithm Example Algorithm Consider the following algorithm: Remainder 1: Request a value for x 2: Request a value for y 3: while x y do 4: assign x-y to x 5: return x 6: end Caller Algorithm A x y

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example Algorithm Example Algorithm Consider the following algorithm: Remainder 1: Request a value for x 2: Request a value for y 3: while x y do 4: assign x-y to x 5: return x 6: end Caller Algorithm A 15 x y
Example Algorithm Example Algorithm Consider the following algorithm: Remainder 1: Request a value for x 2: Request a value for y 3: while x y do 4: assign x-y to x 5: return x 6: end Caller Algorithm A 15 7 x y

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example Algorithm Example Algorithm Consider the following algorithm: Remainder 1: Request a value for x 2: Request a value for y 3: while x y do 4: assign x-y to x 5: return x 6: end Caller Algorithm A 8 7 x y
Example Algorithm Example Algorithm Consider the following algorithm: Remainder 1: Request a value for x 2: Request a value for y 3: while x y do 4: assign x-y to x 5: return x 6: end Caller Algorithm A 1 7 x y

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example Algorithm Example Algorithm Consider the following algorithm: Remainder 1: Request a value for x 2: Request a value for y 3: while x y do 4: assign x-y to x 5: return x 6: end Caller Algorithm A 1 7 x y
Example Algorithm Example Algorithm Consider the following algorithm: Remainder 1: Request a value for x 2: Request a value for y 3: while x y do 4: assign x-y to x 5: return x 6: end Caller Algorithm A 1 7 x y 1 output

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
There are two ways to pass data to There are two ways to pass data to and from the caller and from the caller Pass-by-value copies the data from the caller to a new location in the algorithm Pass-by-reference gives direct access to the data in the caller’s environment
Consider the

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/02/2008 for the course ENGR 101 taught by Professor Ringenberg during the Fall '07 term at University of Michigan.

### Page1 / 44

Lecture03_prepost - Lecture03 Algorithms and Callers...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online