Computer Science, asked by bhavithadesireddy, 3 months ago

Select the correct answer
Test time left: 16:20
Consider the list of elements 1,3,7,9,14,19,45.
Number 14 needs to be searched using BINARY
SEARCH in the following sorted list of numbers:
both
How many comparisons will be required to conclude
that the number 14 is found in the 5th position?
Note: Assume integer division is used for finding the
middle element and the index starts with 0 (zero)
tru​

Answers

Answered by ansarialan31
2

Answer:

3 Comparisons

Explanation:

assign all elements of array from 0 to 6 : {1,3,7,9,14,19,45}

in binary search middle term is taken i.e. 3 {9}

Now as 9 is less than 14 the right half is taken i.e. 3+1 to 6 -> middle term 5 {19} ... comparison 1

Now as 19 is more than 14 the left half is taken i.e. (5-1 to 4) -> term is 4 {14} ...comparison 2

now to check this number a third comparison is made and 14 is found.

Answered by sadiaanam
0

Explanation:

The number of comparisons required to find the number 14 using binary search in the given sorted list is 3. In each comparison, the middle element of the remaining sublist is checked until the target number is found or it is concluded that it is not in the list.

Starting with the full list, the middle element is 9, which is less than 14. So, the right half of the list, [14, 19, 45], becomes the new sublist to search.

The middle element of this sublist is 19, which is greater than 14. So, the left half of the sublist, [14], becomes the new sublist to search.

Since there is only one element in this sublist and it is the target number 14, it can be concluded that 14 is found in the 5th position with 3 comparisons.

Learn more about Binary search :

https://brainly.in/question/54679804

#SPJ3

Similar questions