Learn C++ STL

Lesson 3 of 9 · binary_search, lower_bound, upper_bound and equal_range

Module 13 · binary_search, lower_bound, upper_bound and equal_range

Full Programs: From a Price Check to Binary Search on the Answer

Free with an accountReading

Six jobs follow, and all of them have the same shape: sort once, then answer many questions. A phone shop counts what a budget buys. A library shelf stays in order while books come back. A bakery finds the next van, and a school keeps its phone numbers. Then comes the idea contests love most, binary search on an answer that is not stored anywhere. The last program times the sort against a plain scan, to show when sorting pays. Read the "new thing" line above each program first.

Checking what this lesson needs for you…

What is inside Full Programs: From a Price Check to Binary Search on the Answer

  1. Program 1: how many phones fit a budget
  2. Program 2: a shelf that stays sorted
  3. Program 3: the first van at or after a time
  4. Program 4: a phone directory in a sorted vectorIntermediate
  5. Program 5: binary search on the answerIntermediate
  6. Program 6: does the sort pay for itself?Intermediate