Data Structures & AlgorithmsModerateTCS NQT · Product Company SDE

Problem: The array [4, 2, 5, 1, 3] is turned into a max-heap by sift-down from the last parent to the root (standard heapify, 0-indexed). What is the value at index 0 afterwards?

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

Correct answer: D. 5

Heapify sifts each internal node down from the last internal node up to the root, so the maximum rises to index 0. Building the heap by inserting elements one at a time gives the same root but via a different process.

More Coding Interview Problems questions

Exams that ask this topic