Skip to content
GATEiit

GATE CSE 2019 Q50: True statements about max-heaps and binary search trees

Syllabus topic: Trees, binary search trees and binary heaps

Question

Consider the following statements:

I. The smallest element in a max-heap is always at a leaf node

II. The second largest element in a max-heap is always a child of the root node

III. A max-heap can be constructed from a binary search tree in Θ(n) time

IV. A binary search tree can be constructed from a max-heap in Θ(n) time

Which of the above statements are TRUE?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: A (official GATE 2019 final answer key)

Concept used: Heap order puts every element above its descendants only, so a heap can be built from any array in Θ(n), but a heap carries too little order to build a BST faster than sorting, which needs Ω(nlog⁡n).

Concept notes

Loading notes…

First step: Test I and II with the heap property (a parent is at least each child); for III and IV, ask whether a linear-time conversion would let you sort in linear time.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Trees, binary search trees and binary heaps

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key