Presentation is loading. Please wait.

Presentation is loading. Please wait.

My Take on the Largest Number Algorithm

Similar presentations


Presentation on theme: "My Take on the Largest Number Algorithm"— Presentation transcript:

1 My Take on the Largest Number Algorithm
My take on “largest number” algo… Follow and compare to yours Explain basic flow Then fill in loop… Make sure they see the loop as a separate thing Make sure they see loop termination condition General solution Examine limiting techniques teams tried: # digits in number Enumerating specific numbers Only allowing for positive # Only allowing for integers Algo must be general … work for *ANY* list of numbers Becomes a general tool Reuse Easily extended/changed

2 My Take on the Largest Number Algorithm
Take the 1st number

3 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen

4 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left 5

5 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left <stuff> 6

6 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left 7

7 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list 8

8 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list Compare the current largest to the next number 9

9 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list Compare the current largest to the next number If the next number is larger 10

10 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list Compare the current largest to the next number If the next number is larger Then take it as the largest 11

11 My Take on the Largest Number Algorithm
Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list Compare the current largest to the next number If the next number is larger Then take it as the largest The number you are left with is the largest 12

12 My Take on the Largest Number Algorithm
1) Initialize – get set up Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list Compare the current largest to the next number If the next number is larger Then take it as the largest The number you are left with is the largest 13

13 My Take on the Largest Number Algorithm
1) Initialize – get set up Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list Compare the current largest to the next number If the next number is larger Then take it as the largest The number you are left with is the largest 2) Repeated steps - loop 14

14 My Take on the Largest Number Algorithm
1) Initialize – get set up Take the 1st number – at the start, it is the largest we’ve seen While you have numbers left Get the next number from the list Compare the current largest to the next number If the next number is larger Then take it as the largest The number you are left with is the largest 3) Finish – how to exit the loop 2) Repeated steps - loop 15

15 Visualizing Your Design

16 Visualizing Your Algorithm

17 Visualizing Your Algorithm
Writing it out in English can get cumbersome

18 Visualizing Your Algorithm
Writing it out in English can get cumbersome Seeing the flow of the algorithm can be almost impossible

19 Visualizing Your Algorithm
Writing it out in English can get cumbersome Seeing the flow of the algorithm can be almost impossible What would be nice is a graphical way of representing the algorithm

20 Visualizing Your Algorithm
Writing it out in English can get cumbersome Seeing the flow of the algorithm can be almost impossible What would be nice is a graphical way of representing the algorithm Flowcharts are here to save the day!

21 Flowchart to print the sum of the first 50 natural numbers

22 Flowchart to print the sum of the first 50 natural numbers

23 A more complicated example for troubleshooting CD or DVD playback problems.

24 A more complicated example for troubleshooting CD or DVD playback problems.

25 Basic Flowchart Symbols

26 Basic Flowchart Symbols
Start or end of algorithm

27 Basic Flowchart Symbols
Start or end of algorithm:

28 Basic Flowchart Symbols
Start or end of algorithm:

29 Basic Flowchart Symbols
Start or end of algorithm: Leave the house

30 Basic Flowchart Symbols
Start or end of algorithm: Leave the house At school - done

31 Basic Flowchart Symbols
Start or end of algorithm: Action/process step Leave the house At school - done

32 Basic Flowchart Symbols
Start or end of algorithm: Action/process step: Leave the house At school - done

33 Basic Flowchart Symbols
Start or end of algorithm: Action/process step: Leave the house At school - done Start the car

34 Basic Flowchart Symbols
Start or end of algorithm: Action/process step: Input or output operation Leave the house At school - done Start the car

35 Basic Flowchart Symbols
Start or end of algorithm: Action/process step: Input or output operation: Leave the house At school - done Start the car

36 Basic Flowchart Symbols
Start or end of algorithm: Action/process step: Input or output operation: Leave the house At school - done Start the car Ask for directions

37 Basic Flowchart Symbols
Start or end of algorithm: Action/process step: Input or output operation: Decision Leave the house At school - done Start the car Ask for directions

38 Basic Flowchart Symbols
Start or end of algorithm: Action/process step: Input or output operation: Decision: Leave the house At school - done Start the car Ask for directions Yes No

39 Basic Flowchart Symbols

40 Basic Flowchart Symbols
Connect the boxes with arrows to show logic/process flow.

41 Basic Flowchart Symbols
Connect the boxes with arrows to show logic/process flow. Try to keep things lined up and “clean”.

42 Basic Flowchart Symbols

43 Basic Flowchart Symbols
If you run out of room on a page:

44 Basic Flowchart Symbols
If you run out of room on a page: Try to keep logical things together on the same page.

45 Basic Flowchart Symbols
If you run out of room on a page: Try to keep logical things together on the same page. Connect flow from page to page with a connector symbol:

46 Basic Flowchart Symbols
If you run out of room on a page: Try to keep logical things together on the same page. Connect flow from page to page with a connector symbol: 1 Do some stuff

47 Basic Flowchart Symbols
If you run out of room on a page: Try to keep logical things together on the same page. Connect flow from page to page with a connector symbol: 1 Do some stuff 1 Do some more stuff

48 Practice

49 Practice Flowchart your “select the largest number” algorithm.

50 Practice Flowchart your “select the largest number” algorithm.
Work on refining your “put clothes away” algorithm.

51 Practice Flowchart your “select the largest number” algorithm.
Work on refining your “put clothes away” algorithm. Flowchart your “put clothes away” algorithm.

52 Clear and Unclear Windows


Download ppt "My Take on the Largest Number Algorithm"

Similar presentations


Ads by Google