Skip to main contentSkip to solution

Match List-I with List-II

Consider a sorted list comprising 15 elements:

numList = [2, 3, 5, 7, 10, 11, 12, 17, 19, 23, 29, 31, 37, 41, 43]

List-IList-II
(A) Search for value 7 using linear search(I) Comparison=1
(B) Search for value 17 using binary search(II) Comparison=8
(C) Search for value 17 using linear search(III) Comparison=2
(D) Search for value 7 using binary search(IV) Comparison=4

Solution

✅ Correct Option: 1
List IList II
(A) Linear search for 7(IV) Comparison=4
(B) Binary search for 17(I) Comparison=1
(C) Linear search for 17(II) Comparison=8
(D) Binary search for 7(III) Comparison=2

Linear search checks elements from the start, so the number of comparisons equals the position of the value (counting from 1). 7 is the 4th element and 17 is the 8th.

Binary search starts at the middle index 0+142=7\dfrac{0+14}{2} = 7, which holds 17, so 17 is found in 1 comparison. For 7, the first middle value 17 is too large, so the search narrows to indices 0 to 6. The new middle index is 3, which holds 7, so it takes 2 comparisons.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question