Sorted Search

C++ Algorithmic thinking Public



Implement function countNumbers that accepts a sorted vector of unique integers and, efficiently with respect to time used, counts the number of vector elements that are less than the parameter lessThan.

For example, for vector v containing { 1, 3, 5, 7 }, countNumbers(v, 4) should return 2 because there are two vector elements less than 4.


  •   Example case: Exception
  •   Various small vectors: Exception
  •   Performance test when sortedVector contains lessThan: Exception
  •   Performance test when sortedVector doesn't contain lessThan: Exception