GateAI
Binary Heaps

GATE CSE 2021 Set 2 · Q2

MCQ1 markEasy

Time

Let HH be a binary min-heap consisting of nn elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in HH?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) (n)

Binary Heaps

In a binary min-heap:

  1. The root element is always the minimum element in the heap.

  2. By the min-heap property, every parent node has a value less than or equal to its children. Therefore, the maximum element cannot be an internal node with children; it must reside in one of the leaf nodes.

  3. In a binary heap of nn elements implemented as an array, the leaves are stored from index ⌊n/2⌋+1\lfloor n/2 \rfloor + 1 to nn, which accounts for ⌈n/2⌉\lceil n/2 \rceil elements.

  4. Since the leaf nodes are unordered relative to each other, finding the maximum element requires performing a linear scan over all ⌈n/2⌉\lceil n/2 \rceil leaf elements.

Thus, the worst-case time complexity is Θ(n)\Theta(n) [cite: 1]. Hence, (C) is the correct option.

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 Q2 of the GATE CSE 2021 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 2021 Set 2.

How GATE tests Binary Heaps

More from GATE CSE 2021 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2021 Set 2 · Q2 · MCQ

Let H be a binary min-heap consisting of n elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in H?

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.