Considering the following sorted array and the search key as 89, what will be the sequence of keys in the array that
are compared with 89 while binary searching for 89?
Answers
Answered by
2
Answer:
Considering the following sorted array and the search key as 89, what will be the sequence of keys in the array that
are compared with 89 while binary searching for 89?
w
C
с C
20 30 38 47 48 49 51 67 73 75 78 84 89 92 9
Answered by
0
Answer:
When binary searching for 89, the keys in the array that are compared with 89 are 67, 84, 92, and 89.
Explanation:
- The provided array is 15 bytes long.
- Consequently, in accordance with the binary search strategy, we compare the supplied number (= 89), which is the number we must look for, with the middle element, which is at index 15/2 = 7 and so 67.
- The middle element in the second half would be 84, which is once again less than 89, therefore the next middle element would be 92, which is now more than 89 because 67 is again less than 89.
- So we will finally search in the lower half and the middle element is 89.
As a result, the comparison's order would be 67, 84, 92, and 89.
Similar questions
Biology,
20 days ago
English,
20 days ago
Science,
20 days ago
Social Sciences,
1 month ago
Hindi,
1 month ago
Environmental Sciences,
8 months ago