MyLeoNes™

Algorithms and efficiency — Computing, 14–17 years

An algorithm is a precise plan for solving a problem. Comparing plans by the work they require helps us build programs that remain useful when the input becomes much larger.

A plan with no guessing

An algorithm gives clear steps that can be followed by a person or a machine. It must say what to do, in what order, and when to stop; a vague instruction such as “make it good” is not enough for a computer.

Why efficiency matters

A method that works for ten items may become painfully slow for ten million. Computer scientists therefore ask not only whether an algorithm gives the right answer, but also how its work grows as the input grows.

Finding a name

Suppose 16 sorted names are in a list and you seek “Mira”. Binary search checks the middle, then keeps only the half that could contain Mira: 16 items become 8, then 4, then 2, then 1. It needs at most four checks, rather than up to sixteen.

Fast is not always correct

People often praise an algorithm because it is quick, then forget to test its answers. That is reasonable: speed is easy to notice, while a wrong result may hide in an unusual case. A useful algorithm must be correct first and efficient where its size matters.

Routes and recommendations

Map apps use algorithms to compare possible routes, considering distance, traffic and restrictions. Streaming and shopping services also use algorithms to rank suggestions, but the result reflects the data and rules chosen; it is not a neutral statement of what is best.

Keep exploring

Other languages

Loading MyLeoNes™…