Skip to main contentSkip to solution

Consiser the following linear list 'L':

L=[11,32,17,19,23,29,42]

Determine the number of comparisons a linear search will take to search for key 42.

Solution

✅ Correct Option: 4

Linear search checks the elements one by one from the start, and stops only when it finds the key.

The key 42 is the last element, at position 7 (index 6), so it is compared with every element in the list.

11,32,17,19,23,29,42⇒comparisons=711, 32, 17, 19, 23, 29, 42 \Rightarrow \text{comparisons} = \boxed{7}

In linear search, the number of comparisons for a key equals its position (counting from 1), not its index.

Keyboard Shortcuts

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