Practice question · Match the pairs
Match each data structure to the hot operation it makes fast.
- Heap
- Hash table
- Sorted array
- Queue
- First-in, first-out processing
- Binary search
- Fast lookup by key
- Repeatedly taking the extreme element
Hints
- Pick the structure whose fast operation matches what you do most.
- A heap gives cheap extreme-element access; a hash table gives cheap keyed lookup.
Show the answer
- Heap → Repeatedly taking the extreme element
- Hash table → Fast lookup by key
- Sorted array → Binary search
- Queue → First-in, first-out processing
Why
A heap for repeated extremes, a hash table for keyed lookup, a sorted array for binary search, a queue for FIFO order. The design rule is to make the strategy's hot operation the structure's fast one.
Practise Integrated Algorithm Design Practice
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 Algorithm Design Practice
- A problem is shown to be NP-complete. Why is that useful news rather than merely bad news?
- For 'find the k most frequent words in a huge text', select every design decision the lesson endorses.
- Given a new problem, an experienced programmer often recognises it as a variant of something known - shortest…
- The fastest algorithm for a problem in the abstract is the right choice regardless of the data and…
- Order the first five steps of the design workflow the lesson recommends.