Computers cannot think for themselves; they follow instructions exactly. Before writing a program, a programmer must work out a clear method for solving the problem. This method is the algorithm, and designing it is the most important part of programming. A program is simply an algorithm expressed in a programming language that a computer can execute.
Key terms
- Algorithm
- a step-by-step method for solving a problem
- Program
- an algorithm written in a programming language
- IPO model
- input, process, output
- Sequence
- steps executed in order
- Selection
- choosing a path based on a condition
- Repetition (loop)
- repeating steps
- Variable
- a named value that can change
Summary
- An algorithm is the method; a program is its implementation.
- Algorithms follow the input–process–output model.
- Sequence, selection and repetition build every algorithm.
In everyday life: An ATM follows an algorithm: read card, ask for PIN, check it (selection), allow up to three attempts (repetition), then dispense cash.
Check yourself
- What is the IPO model?
- Name the three basic control structures.
- Give an everyday example of an algorithm.
Practice questions
1. An algorithm reads 4, 9 and 2, adds them and divides by 3. What is the output?
Show answer
Answer: 5
Sum = 4 + 9 + 2 = 15; 15 ÷ 3 = 5. This is the classic averaging algorithm: input, process, output.
On WeLearn
The full lesson: reading notes, worked examples, class activities and the Unit 6 quiz
Study Basics of Algorithms on WeLearnTeach Basics of Algorithms with WeLearn
We will bring a demo to your school: a lesson on your interactive TV, a virtual lab and a classroom game, with your own teachers.
