Computer Science I / Choosing a Data Structure by Workload
Practice question · Put in order

Order the steps of choosing a data structure by workload, as the lesson describes it.

Hints
  1. The workload has to be known before anything about it can be called dominant.
  2. The trade-off can only be weighed once there are candidate structures to weigh.
Show the answer
  1. Write down the mix of operations the program actually performs
  2. Identify which of those operations dominate the hot path
  3. Look up which structures make those operations cheap
  4. Weigh the memory each candidate costs against the time it saves
  5. Choose the structure, or combine two, so the dominant operations are fast
Why

The method runs from evidence to decision: catalogue the operations, find the dominant ones, match structures to them, price the trade-off, then choose. Starting at the last step, by reaching for a familiar structure, is the pitfall the lesson names, habit is not a workload analysis.

Read the lesson: Choosing a Data Structure by Workload →

Practise Choosing a Data Structure by Workload

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 Choosing a Data Structure by Workload