Computer Science I / Integrated Data-Structure Reasoning
Practice question · Sort into groups

Sort each statement about the composed task manager by whether it is a cost or a benefit of the design.

Groups: A cost of composing structures · A benefit of composing structures

Hints
  1. The costs are all about extra memory and extra work to keep the copies consistent.
  2. The benefits are all about an operation whose growth class improved.
Show the answer

A cost of composing structures: Every task is referenced from three separate structures, Adding a task means three insertions, not one

A benefit of composing structures: Extracting the most urgent task is logarithmic rather than linear, Lookup by id stays constant on average however many tasks exist

Why

Composition buys speed on every access pattern at the price of memory and of a consistency obligation on every update. That obligation is real: if a cancelled task is removed from the hash table but left in the heap, the manager will eventually try to run a task that no longer exists.

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