Algorithms: Clear Step-by-Step Problem Solving
Algorithms in everyday life
What makes an algorithm?
An algorithm is a precise sequence of steps designed to solve a problem. A good algorithm should be clear, finite, and correct.
Example: brushing teeth
-
1
Step 1: Put toothpaste on the toothbrush.
-
2
Step 2: Brush all tooth surfaces for about two minutes.
-
3
Step 3: Spit, rinse, and put away the brush.
Algorithms are not just for computers
Any reliable recipe, set of instructions, or procedure can be thought of as an algorithm.
Which property is most important for an algorithm?
Algorithms need to be precise and understandable so they can be followed correctly.
Correct answer: It must be clear and step-by-step
What does it mean for an algorithm to be finite?
A valid algorithm must eventually stop.
Correct answer: It ends after a limited number of steps
Good vs poor algorithms
Good algorithm
- Clear steps
- Produces the correct result
- Eventually ends
Poor algorithm
- Ambiguous instructions
- May never finish
- May give wrong results
A recipe for making a sandwich is best described as a(n):
A recipe is a step-by-step procedure, just like an algorithm.
Correct answer: Algorithm
Give one example of a task that could be turned into an algorithm.
Many answers are possible if they describe a step-by-step task.
Correct answer: Sorting books by height