Practice question · Multiple choice
The lesson's rule is to choose a structure by which operations dominate the workload. Why is 'which structure is fastest?' the wrong question to ask in the first place?
Hints
- Name the structure that beats every other at every operation.
- The question has no answer until something else is specified. What?
Show the answer
A. Because no structure is fastest at everything; each concedes something.
Why
The question is malformed rather than difficult: a hash table cannot produce the smallest element, a tree's lookup is logarithmic, an array's middle insertion is O(n). Every structure is a trade, and the workload — which operations, in what proportion, at what size — is what makes the question answerable. It is also why a composed structure is a legitimate answer rather than a hack.
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
- A hash table serves a workload of 90% lookups by key and 10% requests for the smallest key well, because the…
- Sort each requirement by whether a hash table alone is enough for it.
- Order the steps of choosing a data structure by workload, as the lesson describes it.
- A cache needs fast lookup by key and eviction of the least recently used entry. No single structure does…
- Select every statement the lesson supports about choosing structures.