All labsStart: Bubble sort
Sorting and searching
Sort cards by hand with bubble sort, insertion sort and merge sort, find a number with binary search, and count every comparison as you go.
Briefing
You are handed a row of numbered cards and a counter that clicks every time you compare two of them. Your job is to put the cards in order the way a computer would, one small decision at a time, and to notice which ways cost the fewest clicks.
You'll learn to
- Sort a list step by step with bubble sort, and know when to stop early
- Sort a list with insertion sort, like a hand of cards
- Find a number in a sorted list with binary search, in a handful of checks
- Merge sorted runs into one with merge sort
- Compare algorithms by how many comparisons they need
0 of 6 steps done0%
Stop early
When the list is nearly sorted
Insertion sort
Like sorting a hand of cards
Binary search
Halve the list every time
Merge sort
Sort small pieces, then merge them
How fast is fast?
What you counted, and where it is used