SortedSearch


Algorithmic thinking Searching Public

Hard  

20min


Implement function CountNumbers that accepts a sorted array of integers and counts the number of array elements that are less than the parameter lessThan.

For example, SortedSearch.CountNumbers(new int[] { 1, 3, 5, 7 }, 4) should return 2 because there are two array elements less than 4.

C# 5.0, .NET Framework 4.5
 
 


  •   Example case: System.NotImplementedException at SortedSearch.CountNumbers(Int32[] sortedArray, Int32 lessThan) in SortedSearch.cs:line 7
  •   Various small arrays: System.NotImplementedException at SortedSearch.CountNumbers(Int32[] sortedArray, Int32 lessThan) in SortedSearch.cs:line 7
  •   Performance test when sortedArray contains lessThan: System.NotImplementedException at SortedSearch.CountNumbers(Int32[] sortedArray, Int32 lessThan) in SortedSearch.cs:line 7
  •   Performance test when sortedArray doesn't contain lessThan: System.NotImplementedException at SortedSearch.CountNumbers(Int32[] sortedArray, Int32 lessThan) in SortedSearch.cs:line 7