Lite / Intelligent Robotic Systems / Week 5
Week 5: Search and sorting
This week you will
- Implement linear and binary search and state when binary search applies.
- Implement insertion sort and count its comparisons in the best and worst case.
- Decide when sorting first pays for itself.
Lessons
- Halve it again: binary search · about 40 min
A sorted catalogue lists a million part numbers. How many guesses do you need to find any one, or prove it isn't there? - Insertion sort: tidy as you go · about 40 min
Parts come off a line nearly in order of mass, with the odd one out of place. Which simple sort hardly has to do any work at all? - Sort once, search many: when sorting pays · about 35 min
Sorting 10,000 part numbers costs work up front. After how many lookups has it paid for itself?