Data Structures & AlgorithmsModerateProduct Company SDE · Infosys OA

Problem: The list [25, 14, 9, 31, 7, 18, 3, 12] is turned into a min-heap in place with heapify (standard bottom-up sift-down, 0-indexed). What value is at index 1 afterwards?

  1. A. 9
  2. B. 25
  3. C. 7
  4. D. 14

Correct answer: C. 7

Bottom-up sift-down from index 3 to 0 gives [3, 7, 9, 12, 14, 18, 25, 31], so index 1 holds 7. Building the heap by pushing elements one at a time gives [3, 9, 7, …] (9), a max-heap puts 25 there, and 14 is just the original index-1 value.

More Coding Interview Problems questions

Exams that ask this topic