input: Write a python function to perform binary search on a sorted array.
  assert binary_search([2, 3, 5, 6, 8, 11, 14, 18], 0, 7, 11) == 5
  assert binary_search([2, 3, 5, 6, 8, 11, 14, 18], 0, 7, 6) == 3
  assert binary_search([2, 3, 5, 6, 8, 11, 14, 18], 0, 7, 1) == -1
output: def binary_search(arr, left, right, x):
      while left <= right:
          mid = left + (right - left) // 2
          if arr[mid] == x:
              return mid
          elif arr[mid] < x:
              left = mid + 1
          else:
              right = mid - 1
      return -1