Feb 23
Discuss the assignment due today.
My solutions the homework are in the
hw feb23 folder.
Questions about anything so far?
searching and sorting
On to the the next chapter : you should read it, eh?
Go over the big picture of what's in here :
Searching :
- sequential search : O(n) ... even if list is sorted.
- binary search : O(log(n)) ... only applicable if list is sorted
- hashing : O(1) lookup ... with some caveats (e.g. collisions)
- data structure "Map" (badly named IHMO) ... API like python dict
Sorting :
- bubble sort ... O(n**2) , swap adjacent to push bigger up
- selection sort ... O(n**2) , fewer swaps
- insertion sort ... O(n**2) again
- shell sort ... can be O(n**1.5) with clever sublist skip sizes
- merge sort .. O(n log(n)) ... recursive "divide and conquer". Needs memory overhead.
- quick sort ... O(n log(n)) typical; O(n**2) worst ; uses "pivots". In place.
- radix sort ... O(n M) where M = range of values (not in text but worth mentioning)
Are we having fun yet?