Practice question · Multiple choice
A task manager keeps tasks in a hash map, a heap and a sorted list. A delete updates two of the three. When does the bug surface?
Hints
- The delete raises no error. Ask what state it leaves behind.
- Which structure still holds the task, and what happens the next time it is consulted?
Show the answer
B. Later and elsewhere, when run_next() returns a task the map cannot find
Why
The delete succeeds silently and the heap keeps a task nobody can look up, so the crash lands in code that did nothing wrong. That distance between cause and symptom is what makes composed structures hazardous, and precisely why the previous lesson's invariant checker earns its cost.
Practise Integrated Data-Structure Reasoning
The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Integrated Data-Structure Reasoning
- The manager holds 1024 tasks. Order these operations from cheapest to most expensive.
- The task manager keeps every task in a hash table, a heap and a list at once. What does that composition buy,…
- Sort each statement about the composed task manager by whether it is a cost or a benefit of the design.
- Select every edge case the lesson says the task manager should be tested against.
- If three structures each hold their own copy of which tasks exist, any update must change all three or they…