Java: Convert Min Heap to Max Heap

Level : Intermediate
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:30:00

Lab Details

Problem Statement:

Given an array representation of min Heap, convert it to max Heap.

Input:

arr[] = {3, 5, 9, 6, 8, 20, 10, 12, 18, 9}
3
/ \
5 9
/ \ / \
6 8 20 10
/ \ /
12 18 9

Output:

arr[] = {20, 18, 10, 12, 9, 9, 3, 5, 6, 8}
  20
  / \
 18  10
/ \  / \
12 9 9 3
/ \ /
5 6 8
Self-paced Membership
  • 22+ Courses
  • 750+ Hands-On Labs
  • 200+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A
  • 10+ Real-world Projects
  • Career Coaching
  • Email Support
Upto 66% OFF
KNOW MORE..

To get full access to all courses

Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this