Lecture03_prepost - Lecture03 Algorithms and Callers...

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

View Full Document Right Arrow Icon
Engineering 101 Engineering 101 Lecture03 Lecture03 Algorithms and Callers Algorithms and Callers Prof. Michael Falk University of Michigan, College of Engineering
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
Every algorithm has a caller Every algorithm has a caller An algorithm is usually called by another algorithm. Caller Algorithm A
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
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
Background image of page 12
Consider the
Background image of page 13

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

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online