Lesson 3: What does 'efficient' mean? Counting steps
Welcome! We already saw that an algorithm is a list of steps. Now we ask a new, important question: when is an algorithm considered 'efficient'? The simple answer: when it does fewer steps to reach the same result. To feel this, we'll learn one tiny skill — counting how many steps an algorithm takes
'Efficient' means 'doing less work for the same result'. Like finding a name in a phone book: flipping page by page is many steps, but a smart jump to the middle saves a lot. In this lesson we'll simply count steps, and see that as the list grows — the number of steps grows too.
- efficiency
- How little work (steps) an algorithm does to reach the same result — fewer steps = more efficient.
- step
- One small action the algorithm performs, e.g. looking at a single item in the list.
- input size
- How many items are in the input — e.g. the length of the list. As it grows, there are usually more steps.