A 3-ary max heap is like a binary max heap, but each node can have up to 3…

GATE · 2006 · CSModified — slightly modified from the official paper; see the solution

A 3-ary max heap is like a binary max heap, but each node can have up to 3 children. In a 0-based array representation, the root is stored at a[0], the next level is stored from a[1] to a[3], and the following level starts from a[4].

The current valid 3-ary max heap is [9, 5, 6, 8, 3, 1]. An item x is inserted by placing it at a[n] and pushing it up until the max-heap property is satisfied.

Suppose the elements 7, 2, 10 and 4 are inserted in that order. Which sequence represents the resultant heap array?

  1. A.

    10, 7, 9, 8, 3, 1, 5, 2, 6, 4

  2. B.

    10, 9, 8, 7, 6, 5, 4, 3, 2, 1

  3. C.

    10, 9, 4, 5, 7, 6, 8, 2, 1, 3

  4. D.

    10, 8, 6, 9, 7, 2, 3, 4, 1, 5

Attempted by 208 students.

Show answer

Correct answer: A

The worked solution is available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…