input: Write a function to implement a binary search algorithm in Python, which efficiently finds an item in a sorted list of items. The function should return the index of the item if found, otherwise return -1. If the given list is empty then return -1.
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 8)==5
  assert binary_search([1, 2, 3, 4, 5, 6, 7], 4)==3
  assert binary_search([10, 20, 30, 40, 50], 60)==-1
  assert binary_search([], 1)==-1
output: def binary_search(arr, x):
      if not arr:
          return -1
      low, high = 0, len(arr) - 1
      while low <= high:
          mid = (low + high) // 2
          if arr[mid] == x:
              return mid
          elif arr[mid] < x:
              low = mid + 1
          else:
              high = mid - 1
      return -1