Question:

An array \( [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] \) is heapified. Which one of the following options represents the first three elements in the heapified array?

Show Hint

In a max heap, the root is always the largest element, and the heap property ensures that each subtree also satisfies this rule.
Updated On: Jan 22, 2025
  • \( 82, 90, 101 \)
  • \( 82, 11, 93 \)
  • \( 131, 11, 93 \)
  • \( 131, 111, 90 \)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Understanding heapification.
Heapification transforms an array into a binary heap. In a max heap, the root node is the largest element, and every parent node is larger than its child nodes. Step 2: Applying heapification to the array.
Starting with \( [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] \):
1. The largest element \( 131 \) becomes the root.
2. The next largest elements, \( 111 \) and \( 90 \), are placed as the left and right children of the root, respectively. Step 3: First three elements.
After heapification, the first three elements in the max heap are: \[ \boxed{131, 111, 90}. \]
Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions