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
My Take on the Largest Number Algorithm Take the 1st number
My Take on the Largest Number Algorithm Take the 1st number – at the start, it is the largest we’ve seen
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
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
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
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
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
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
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
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
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
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
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
Visualizing Your Design
Visualizing Your Algorithm
Visualizing Your Algorithm Writing it out in English can get cumbersome
Visualizing Your Algorithm Writing it out in English can get cumbersome Seeing the flow of the algorithm can be almost impossible
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
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!
Flowchart to print the sum of the first 50 natural numbers
Flowchart to print the sum of the first 50 natural numbers
A more complicated example for troubleshooting CD or DVD playback problems.
A more complicated example for troubleshooting CD or DVD playback problems.
Basic Flowchart Symbols
Basic Flowchart Symbols Start or end of algorithm
Basic Flowchart Symbols Start or end of algorithm:
Basic Flowchart Symbols Start or end of algorithm:
Basic Flowchart Symbols Start or end of algorithm: Leave the house
Basic Flowchart Symbols Start or end of algorithm: Leave the house At school - done
Basic Flowchart Symbols Start or end of algorithm: Action/process step Leave the house At school - done
Basic Flowchart Symbols Start or end of algorithm: Action/process step: Leave the house At school - done
Basic Flowchart Symbols Start or end of algorithm: Action/process step: Leave the house At school - done Start the car
Basic Flowchart Symbols Start or end of algorithm: Action/process step: Input or output operation Leave the house At school - done Start the car
Basic Flowchart Symbols Start or end of algorithm: Action/process step: Input or output operation: Leave the house At school - done Start the car
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
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
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
Basic Flowchart Symbols
Basic Flowchart Symbols Connect the boxes with arrows to show logic/process flow.
Basic Flowchart Symbols Connect the boxes with arrows to show logic/process flow. Try to keep things lined up and “clean”.
Basic Flowchart Symbols
Basic Flowchart Symbols If you run out of room on a page:
Basic Flowchart Symbols If you run out of room on a page: Try to keep logical things together on the same page.
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:
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
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
Practice
Practice Flowchart your “select the largest number” algorithm.
Practice Flowchart your “select the largest number” algorithm. Work on refining your “put clothes away” algorithm.
Practice Flowchart your “select the largest number” algorithm. Work on refining your “put clothes away” algorithm. Flowchart your “put clothes away” algorithm.
Clear and Unclear Windows