Module 8 · set and multiset: Sorted, Unique, Found in log n
When to Use set, a Sorted vector or a Hash Set, and When Not To
Free with an accountReading
Maria keeps the different scores of her game in a sorted vector. Every new score goes in at its place, and the game then shows the next score to beat. Kenji uses a set for everything, even for a list he fills once and then searches a million times. Both programs work, and Amara asks each of them one question: what did the job need? This lesson is her answer, with a chart, a flowchart and two measurements.
Checking what this lesson needs for you…
What is inside When to Use set, a Sorted vector or a Hash Set, and When Not To
- Six questions before you pick
- The comparison chart
- The decision flowchart
- Kenji's tickets, measured: fill once, ask a million times
- Maria's scores, measured: values that keep arriving
- The honest default
- When not to use a set
- flat_set: a sorted vector that looks like a set