Lesson 12 · Python
Algorithms: Searching & Sorting
Implement linear and binary search, trace them by hand, sort with insertion sort for learning and with Python's built-in Timsort for real work.
Prerequisites: Algorithms: Complexity & Big-O
Learning objectives
By the end of this lesson, you will be able to:
- Implement linear and binary search and choose between them honestly
- Trace binary search by hand, including its sorted precondition and loop invariant
- Implement insertion sort and state its best and worst cases
- Explain what makes a sort stable and why it matters
- Sort real data professionally with sorted() and list.sort(key=...)