Consider a 3-ary max heap (each node has up to 3 children) represented using…

Consider a 3-ary max heap (each node has up to 3 children) represented using an array (0-based indexing). The parent index is given by ⌊(i − 1)/3⌋ and children indices are 3i + 1, 3i + 2, 3i + 3.

The initial valid 3-ary max heap is:
[9, 5, 6, 8, 3, 1]

a) Insert the elements 7, 2, 10, and 4 in the given order and show the changes in the heap after each insertion.

b) Write the final array representation of the heap.

c) Explain how the heap property is maintained during insertion in a 3-ary max heap.

Attempted by 2 students.

Sign up free to check your answer

Sign up free

Explore the full course: Data Structures

Loading lesson…