MyLeoNes™

Searching data — Computing, 11–13 years

How a computer finds one item among many, and why order can help. Computing, 11–13 years.

Finding one thing

Searching means looking through stored information to find the item that matches a question. A computer might look for a name in contacts, a title in a library catalogue or a high score in a game. The method matters because checking every item becomes slow when the collection grows.

Why order changes the search

The problem is not finding one item in a short row; it is finding one in millions without wasting time. If the items are sorted, a computer can compare with a middle item and discard the half that cannot contain the answer. This idea grew from the need to search large lists, catalogues and indexes quickly.

Searching 1 to 100

The list contains the numbers 1 to 100, in order, and we seek 73. Check 50: 73 is higher, so ignore 1–50. Check 75: 73 is lower, so keep 51–74. Check 62, then 68, then 71, then 73. Six checks find the answer, instead of potentially 73 checks from the front.

It only works with the right order

A common mistake is to use the middle-and-discard method on a mixed-up list. That feels reasonable because the target is still somewhere in the list, but the middle value gives no clue about which half to remove. The fast method needs a sorted list; otherwise, checking items one by one may be safer.

Search boxes and maps

A search box on a shop, music service or school library may examine thousands of records in a moment. Map apps also search names and locations, often using prepared indexes rather than starting from the first place every time. The same idea helps a game find a player or an app find a saved file.

Keep exploring

Other languages

Loading MyLeoNes™…