apply binary search technique for the following sequence of numbers to search the position of the element 35 10 20 30 35 40 45 50 55 60
Answers
Answer:
If we find the position of the number 67 in the array, we can use that to figure out how many smaller primes exist. The position of an element in an array is known as its index. ... Looking through the numbers in order like this is a linear search. ... The binary search algorithm stops at this point
Explanation:
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
the numbers are different refer and write