Question: def binary_search (searchvalue, searchlist): start = 0 position=0 end = len (searchlist) -1 while (start searchlist [position]: start = position + 1 else: end =position-1
def binary_search (searchvalue, searchlist): start = 0 position=0 end = len (searchlist) -1 while (start <= end): position = int ((start + end) / 2) if searchlist [position] == searchvalue : return position elif searchvalue> searchlist [position]: start = position + 1 else: end =position-1 return -1 list = [ 23,12,44,9,3,8,1,7,0,2,4,55 ] print ("List:", 1st list) search = int (input ("Enter the value to search in this list")) pos = binary_search (search, list) print ("The value to search", search, "is in position", pos) input ( "Press a key to end") def sort bubble (list,size) : for i in range (1, size) : for j in range (0, size-i): if (list[j] >list[j+1] ) : k=list[ j+1] list[j+1] = list[j] list[j]=k def sort_selection (list, size) : for i in range (0, size-1) : min=i for j in range (i+1, size) : if list[min] > list[j] : min=j aux =list[min] list[min] =list[i] list[i] =aux def insert sort (list, size) : for i in range (1, size): v=list[i] j=i-1 while j >= 0 and list[j] > v: list[j+1] = list[j] j=j-1 list[j+1] =v For the next set of numbers, [23,12,44,9,3,8,1,7,0,2,4,55,11] a) Indicates the passes that are must do to find the number 1. b) Indicate the number of comparisons made. c)Then take the given set of numbers and use the search binary to find the number 1. d)Give the number of positions and comparisons made in the Binary search ---Conditions of the program to execute--- Kindly use python, I have provided the codes of Binary Search , Insert Method , Bubble Method , Sort Method , as help
IMPORTANT. the program must use ONLY THE WHILE LOOP, ONLY THE WHILE LOOP!
the provided codes use the FOR , they also use the IF , that is prohibited in the program that I need
just use while loop
------VERY IMPORTANT----- the program must include the 4 methods (binary search, selection method, insertion method, bubble method) they must perform the same conditions of the problem, and all of them must be in the program
You can only use while loop, In addition, it is forbidden for the program to use python functions, IF THE PROGRAM DOES NOT MEET ALL THE REQUIREMENTS, ITS GRADE WILL BE ZERO THE MINIMUM ZERO MARK
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
