GateAI
Binary Heaps

GATE CSE 2014 Set 2 · Q12

MCQ1 markEasy

Time

A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is:

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) 10, 8, 7, 3, 2, 1, 5

Binary Heaps

Initially, the heap elements in level-order (array representation) are:

[10,8,5,3,2][10, 8, 5, 3, 2]
  1. Insert 1:

    • 1 is added at index 6 (as the left child of node 5 at index 3).

    • Since 1≤51 \le 5, no swapping is needed.

    • Heap array becomes: [10,8,5,3,2,1][10, 8, 5, 3, 2, 1]

  2. Insert 7:

    • 7 is added at index 7 (as the right child of node 5 at index 3).

    • Heap array before bubbling up: [10,8,5,3,2,1,7][10, 8, 5, 3, 2, 1, 7]

    • Compare 7 with its parent 5: since 7>57 > 5, swap 7 and 5.

    • Heap array becomes: [10,8,7,3,2,1,5][10, 8, 7, 3, 2, 1, 5]

    • Compare 7 with its new parent 10: since 7≤107 \le 10, heap property is satisfied.

The resulting level-order traversal is 10, 8, 7, 3, 2, 1, 5, which corresponds to option (A).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Binary Heaps previous year question is Q12 of the GATE CSE 2014 Set 2 paper. Find more GATE CSE PYQs on Binary Heaps in Programming and Data Structures, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Binary Heaps PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Binary Heaps in GATE CSE

Binary Heaps has 15 GATE CSE PYQs across 13 papers from 2011 to 2026. 6 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2014 Set 2.

How GATE tests Binary Heaps

More from GATE CSE 2014 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 2 · Q12 · MCQ

A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is:

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.