209k views
1 vote
Given list: (10, 11, 26, 29, 58, 65, 74, 78, 85)

Which list elements will be compared to key:
a. 85 using binary search? ___________ (comma between values)
b. 85 using linear search? ____________

1 Answer

5 votes

Final answer:

In binary search, the elements 74, 78, and 85 will be compared to 85. In linear search, the elements 10, 11, 26, 29, 58, 65, 74, 78, and 85 will be compared to 85.

Step-by-step explanation:

a. 85 using binary search: In binary search, the key is compared with the element in the middle of the list. If the key is greater than the middle element, then the search continues in the upper half of the list. In this case, the elements that will be compared to 85 are 74, 78, and 85.

b. 85 using linear search: In linear search, each element in the list is compared to the key one by one, until a match is found or the end of the list is reached. In this case, the elements that will be compared to 85 are 10, 11, 26, 29, 58, 65, 74, 78, and 85.

User Toringe
by
8.1k points