Practice Algorithm in CS Thinking
Use these practice problems to test your method after reviewing the concept explanation and worked examples.
Quick Recap
A step-by-step set of instructions for solving a problem or accomplishing a specific task.
A recipe for solving problemsβfollow the steps, get the answer.
Example 1
easyWrite an algorithm (as numbered steps) for making a cup of tea.
Example 2
mediumHere is an algorithm: 1. Set total = 0. 2. For each number in the list [3, 7, 2, 8]: add the number to total. 3. Output total. What does this algorithm compute?
Example 3
easyWrite an algorithm to find the largest number in a list of three numbers: A, B, C.
Example 4
easyA recipe says, 'Add sugar until it tastes right.' Explain why this is a poor algorithm step and rewrite it so it is precise.