Computer Science I / Integrated Data-Structure Reasoning
Practice question · Multiple choice

The task manager keeps every task in a hash table, a heap and a list at once. What does that composition buy, and what new class of bug does it create?

Hints
  1. Three structures, one collection. What has to be true after every insertion and deletion?
  2. Suppose a delete updates two of the three. When does that failure surface?
Show the answer

C. Each operation gets its best structure; the three views can disagree.

Why

Each access pattern gets the structure suited to it, so no operation pays for another's convenience. The cost is a correctness obligation nothing in the language enforces: a delete that updates the table and the list and forgets the heap leaves a task nobody can look up which run_next() still returns. A shared update function helps until someone adds a second code path.

Read the lesson: Integrated Data-Structure Reasoning →

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