Binary Search

Write a class BinarySearcher with no instance variables and a method search that takes two parameters:

  1. a list of sorted numeric values to be searched
  2. a numeric value that may be in the list

If the "target value" is on the list, its index (position) is returned. Otherwise, None is returned.

Test your program with the following lists and target values to see if it works. When testing your program, be sure to look for an item that is on the list, and also an item that isn't on the list.

List to search                  Item to look for    Expected result
--------------                  ----------------    ---------------
[1, 2, 3, 4, 7, 9, 13, 14, 20]      7               4
[1, 2, 3, 4, 7, 9, 13, 14, 20]      1               0
[1, 2, 3, 4, 7, 9, 13, 14, 20]      20              8
[1, 2, 3, 4, 7, 9, 13, 14, 20]      -2              None
[1, 2, 3, 4, 7, 9, 13, 14, 20]      23              None
[1, 2, 3, 4, 7, 9, 13, 14, 20]      10              None
[4, 7, 9, 13, 14, 20]               9               2
[4, 7, 9, 13, 14, 20]               13              3
[4, 7, 9, 13, 14, 20]               20              5
[4, 7, 9, 13, 14, 20]               2               None
[4, 7, 9, 13, 14, 20]               10              None
[4, 7, 9, 13, 14, 20]               22              None