Data Structures & AlgorithmsEasyHCL · Tech Mahindra pattern

Linear search looks for a key that is NOT in an unsorted array of 100 elements. How many key comparisons does it make?

  1. A. 50
  2. B. 99
  3. C. 100
  4. D. 7

Correct answer: C. 100

To be sure the key is absent, every one of the 100 elements must be compared. 50 is the average for a successful search; 7 is the binary-search figure, which needs sorted data.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic