<prompt> Implement a given algorithm.Binary Search  <response>: Sure, here is an implementation of the binary search algorithm in Python:pythondef binary_searcharr, low, high, x: if high low: mid high low 2 if arrmid x: return mid elif arrmid x: return binary_searcharr, low, mid - 1, x else: return binary_searcharr, mid 1, high, x else: return -1This algorithm searches for a value x in a sorted array arr. It begins by calculating the midpoint of the array and checking if the value at that position is equal to x. If it is, then that position is returned. If the value is greater than x, then the algorithm is recursively called on the left half of the array. If the value is less than x, then the algorithm is recursively called on the right half of the array. If x is not found in the array, then the function returns -1. 