Step-by-step problem solving
Algorithms: Step-by-Step Problem Solving
Key Points
- An ALGORITHM is a clear, step-by-step set of instructions that solves a problem
- Good algorithms are: finite (they end), clear (no ambiguity), and effective (they actually work)
- Even recipes are algorithms — they have inputs (ingredients), steps (instructions), and output (the dish)!
- Computers run algorithms billions of times per second to do everything from searches to games
📘 Examples
❓ Write an algorithm to find the largest number in: 5, 3, 8, 1
✅ 1. Assume first number (5) is largest. 2. Compare to next: 3 < 5, no change. 3. Compare 8 > 5 → new largest = 8. 4. Compare 1 < 8. Done! Largest = 8!
❓ Is a recipe an algorithm? Why?
✅ Yes! Recipes have: INPUT (ingredients), PROCESS (step-by-step instructions), and OUTPUT (the finished dish). That's an algorithm!
❓ How would an algorithm tell if a number is even?
✅ Step 1: Divide the number by 2. Step 2: If the remainder is 0, it's EVEN. If the remainder is 1, it's ODD. That's it — 2 steps!
🌟 Fun Fact!
The word 'algorithm' comes from the name of a 9th-century Persian mathematician: Muhammad ibn Musa al-Khwarizmi. His name was Latinized to 'Algoritmi' and eventually became 'algorithm'! 📜