Data Structures & AlgorithmsVery hardTCS NQT · Accenture

Three sorted lists [1, 4, 7], [2, 5, 8] and [3, 6, 9] are merged into one sorted list. What is the value at position 5 (1-based)?

  1. A. 6
  2. B. 7
  3. C. 5
  4. D. 9

Correct answer: C. 5

The merged list is 1 through 9 in order, so position 5 holds 5. A heap-based merge gives the same result in O(N log k).

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

Exams that ask this topic