TAOCP Vol 1: Fundamental Algorithms · Week 37
TAOCP 2.2.4 Circular Lists: reading guide
Lists whose last node points back to the first, which makes some operations simpler. The main example is adding and multiplying polynomials stored as circular lists of terms.
Time About 5 hours this week
Why it matters
Circular lists are used in schedulers, LRU caches and buffer rings. The polynomial example is a great exercise in pointer surgery.
Before you start
- 2.2.3 Linked Allocation
How to approach it
Implement polynomial addition with circular linked lists in C, following the algorithm in the text. Test with polynomials that cancel terms.
Exercises
Work every exercise rated 10 to 20; most are about tracing the algorithm by hand or tweaking one step, which is exactly the skill you want. Pick one or two rated 20 to 25 that involve modifying the algorithm and implement your modification in a real language with tests. Skip HM exercises unless you enjoy calculus, and treat anything rated 40+ as a research problem, not homework.
Traps
- Infinite loops when traversing a circular list without a sentinel or stop condition.