edited by
7,363 views
24 votes
24 votes

Statement for Linked Answer Questions 76 & 77:

A $3$-ary max heap is like a binary max heap, but instead of $2$ children, nodes have $3$ children. A $3$-ary heap can be represented by an array as follows: The root is stored in the first location, $a[0]$, nodes in the next level, from left to right, is stored from $a[1]$ to $a[3]$. The nodes from the second level of the tree from left to right are stored from $a[4]$ location onward. An item $x$ can be inserted into a $3$-ary heap containing $n$ items by placing $x$ in the location $a[n]$ and pushing it up the tree to satisfy the heap property.

76. Which one of the following is a valid sequence of elements in an array representing $3-$ary max heap?

  1. $1,3,5,6,8,9$
  2. $9,6,3,1,8,5$
  3. $9,3,6,8,5,1$
  4. $9,5,6,8,3,1$


77. Suppose the elements $7, 2, 10$ and $4$ are inserted, in that order, into the valid $3$-ary max heap found in the previous question, Q.76. Which one of the following is the sequence of items in the array representing the resultant heap?

  1. $10, 7, 9, 8, 3, 1, 5, 2, 6, 4$
  2. $10, 9, 8, 7, 6, 5, 4, 3, 2, 1$
  3. $10, 9, 4, 5, 7, 6, 8, 2, 1, 3$
  4. $10, 8, 6, 9, 7, 2, 3, 4, 1, 5$
edited by

2 Answers

Best answer
21 votes
21 votes

Heap will be constructed like this, based on the correct answer of Q.76 $($which is $\quad9\quad5\quad 6 \quad8\quad 3\quad 1)$

Correct Answer: $A$

0 votes
0 votes
heap will be like this in the start               @                               suppose = @ is a node with no value filled. We know exactly

                                                 @               @             @                 how heapify going to work . for example 7 will be move

                                       @    @    7      2    10     4                           upward from it's current  leaf  position to root node path.

                                                                                                                if you  draw each and every heap from the options.                                                                                                                       you can  see  there is only 'A' option, which has 7 on its 2nd level right position that is it's parent position. so, option 'A'.

Note ; as for 10 it will move to root node with it's own path
Answer:

Related questions

44 votes
44 votes
5 answers
2
Rucha Shelke asked Sep 16, 2014
20,571 views
In a binary max heap containing $n$ numbers, the smallest element can be found in time $O(n)$ $O(\log n)$ $O(\log \log n)$ $O(1)$