Grade 8 · Media & Informatics
Follow and compare simple sorting and searching algorithms.
Computers spend a lot of time putting things in order (sorting) and finding things (searching). A simple sorting algorithm compares items two at a time and swaps them if they are in the wrong order, repeating until the whole list is in order — much like sorting a hand of cards by sliding each one into place.
To find an item, the simplest method is a linear search: start at the beginning and check every item one by one until you find it. It always works, but on a long list it can be slow because you might check almost everything.
If the list is already sorted, you can search far faster. A binary search jumps to the middle, decides whether the target is in the lower or upper half, throws away the other half, and repeats. Halving the list each time finds an item in a huge list in very few steps — which is why sorting first is often worth the effort.
Have a go right here. Nothing is saved and you can retry as much as you like. Create a free account when you want to save your progress and get Archie, your tutor.
Create a free account to save your progress, track mastery and ask Archie, your tutor, for a hand.
Already with us? Open this lesson in learncoach.ch for mastery tracking and Archie, your tutor.