Choosing structures and finding bugs
How to match a problem to a structure by the operations it needs, and how to find the memory and index bugs that data structure code attracts.
About 4 hours of study
Learning objectives
- Compare structures by the cost of each operation
- Pick a structure from the description of a problem
- Recognise use after free, NULL access and index overflow
- Test the empty, one-item, first and last cases
Lessons
- 1
Choosing a data structure
The cost of each operation on every structure in this course, side by side, and how to pick one for a problem.
- 2
Data structure bugs
Popping an empty stack, reading a node after freeing it, and a queue that runs off its array: three bugs StepVioz stops for you.
Module practice
- Seen before?Easy
- Browser historyMedium
- Most urgent task firstHard
- Fix: free every nodeEasy
- Fix: the queue that runs out of roomMedium
- Fix: delete from a listHard