Algorithm & Core Algorithm Properties
An algorithm is a finite, unambiguous, step-by-step set of instructions that transforms input data into the desired output within a finite number of steps.
How It Works & Why It Matters
School computer science teaches three key properties: Precision (no ambiguous steps), Generality (works for any valid inputs, not just one hardcoded example), and Finiteness (always terminates).
Every algorithm can be built using just three control structures: sequence, selection (if/else), and iteration (loops).
1. Sequence (Linear): Step 1 -> Step 2 -> Step 3
2. Selection (Branch): if (condition) { ... } else { ... }
3. Iteration (Loop): while (...) { ... } / for (...) { ... }
🏫 Classroom Example
Calculating an average: read 3 test scores -> compute sum -> divide sum by 3.0 -> print result.
⚖️ Algorithm vs. Source Code
An algorithm is the abstract logical method; a program implements that algorithm in a concrete language like C++ or Scratch.
Writing an infinite while loop that forgets to update its counter or condition, violating finiteness.