def test_search(): input = INPUT_ARRAY[:] sort.merge(input) search = Search(input) search.binarySearch(7)
print("Array: {}".format(array)) s = Search(array) valueToSearch = input("Insert the value you want to search: ") while True: try: if typeArray == "i": valueToSearch = int(valueToSearch) break except Exception as e: print(e) valueToSearch = input("Insert the value you want to search: ") needsToSort = input( "The array is already sorted? (Y/n) \n**It is important to the binary search " ) while needsToSort.lower() != "y" and needsToSort.lower() != "n": needsToSort = input("The array is already sorted? (Y/n) ") if needsToSort.lower() == "n": array = s.mergeSort(array) print(array) positionLinear = s.linearSearch(valueToSearch) positionBinary = s.binarySearch(0, len(array) - 1, valueToSearch) print("The position of element is: {}".format(positionBinary)) print("============== Execution time ==============") s.executionTime(array)