<prompt> Kutekeleza algorithm binary search kupata idadi fulani katika safu iliyopangwa.Orodha iliyotengwa 2, 3, 6, 7, 8, 10, 12 Idadi ya kutafuta 8  <response>: Sure, here is a Python implementation of a binary search algorithm that finds the given number in a sorted array:pythondef binary_searcharr, x: low 0 high lenarr - 1 mid 0 while low high: mid high low 2 If x is greater, ignore left half if arrmid x: low mid 1 If x is smaller, ignore right half elif arrmid x: high mid - 1 means x is present at mid else: return mid If we reach here, then the element is not present return -1 Test the codearr 2, 3, 6, 7, 8, 10, 12x 8result binary_searcharr, xif result ! -1: printElement is present at index, strresultelse: printElement is not present in arrayIn this code, the binary_search function takes two arguments, the sorted array arr and the number to search x. The function uses a while loop to divide and narrow down the search range by ignoring the right or left half of the range depending on whether the number we are searching is greater or smaller than the middle element, until it finds the element or the search range is empty. If the number is found, the function returns its index in the array, and if it is not, it returns -1 to indicate that the number is not present in the array. 