apply binary search technique for the following sequence of numbers 10,20,30,35,40,45,50 to search the position of the element 40 ANSWER ONLY IF YOU KNOW PLEASE!
Answers
Answered by
2
Low = 0, High = 8 search_ele = 35 Mid_ele_idx = (low + high)/2 = (0+8)/2 = 4 Is 40 = 35? No The list now is 10 20 30 35 Low =0, high= 3 Mid_ele_idx = (low + high) /2 = (0+3)/2 = 1 Is 20 = 35? No The list now is 30 35 Low = 2, high = 3 Mid_ele_idx = (low + high)/2 = (2+3)/2 = 2 Is 30 = 35 No The list now is 35 Low = 3, high = 3 Mid_ele_idx = (low + high) fl = (3+3)/2 = 3 Is 35 = 35 yes location = 3 Output: The search element 35 is found at location 3.
Hope it's helpful for you....
Answered by
2
Answer:
Low = 0, High = 8 search_ele = 35 Mid_ele_idx = (low + high)/2 = (0+8)/2 = 4 Is 40 = 35? No The list now is 10 20 30 35 Low =0, high= 3 Mid_ele_idx = (low + high) /2 = (0+3)/2 = 1 Is 20 = 35? No The list now is 30 35 Low = 2, high = 3 Mid_ele_idx = (low + high)/2 = (2+3)/2 = 2 Is 30 = 35 No The list now is 35 Low = 3, high = 3 Mid_ele_idx = (low + high) fl = (3+3)/2 = 3 Is 35 = 35 yes location = 3 Output: The search element 35 is found at location 3.
Hope it's helpful for you....
Please brainlest me the
Similar questions