Discussion
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?
Answer: D
The first three elements are 131, 111, 90.
Heapify here builds a max-heap bottom-up, sifting down from the last internal node (index 4, value 111) to the root:
- 111 already exceeds its child 93.
- 11 swaps with its larger child 131.
- 90 stays above 75 and 33.
- 101 swaps with 131, then stays above 11 and 44.
- 82 swaps with 131, then with 111, then with 93.
The result is [131, 111, 90, 101, 93, 75, 33, 11, 44, 82]. The root must be the maximum, 131, which rules out the options starting with 82. Option C puts 11 at index 1, above larger elements such as 101, which a max-heap forbids.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development