Module 13 · binary_search, lower_bound, upper_bound and equal_range
When to Use Binary Search, a set, a Hash or a Plain Scan, and When Not To
Free with an accountReading
Kenji loves binary search so much that he keeps a vector sorted the hard way: after every new value, he sorts the whole vector again. His program works. Zara reads it and asks two questions before anything else. How many values are there, and when do they arrive? This lesson is about those two questions, with a chart, a flowchart, three measurements and the jobs where binary search should stay home.
Checking what this lesson needs for you…
What is inside When to Use Binary Search, a set, a Hash or a Plain Scan, and When Not To
- Five questions before you pick
- The comparison chart
- The decision flowchart
- Lab 1: a million keys, three containers
- Lab 2: where a plain scan stops winning
- Lab 3: the list trap
- When not to use binary search
- The honest default