Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE CS 2019 | Question 49

  • Last Updated : 02 Dec, 2019

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 is/are TRUE?
(A) II, III and IV
(B) I, II and III
(C) I, III and IV
(D) I, II and IV

Answer: (B)

Explanation: Statement (I) is correct. In a max heap, the smallest element is always present at a leaf node. So we need to check for all leaf nodes for the minimum value. Worst case complexity will be O(n)

        /  \
      /      \
    8         7
   / \        / \
 /     \    /     \
2      3   4       5 

Statement (II) is also correct, otherwise it will not satisfy max-heap property.

Statement (III) is also correct, as build-heap always takes Θ(n) time, (Refer: Convert BST to Max Heap).

Statement (IV) is false, because construction of binary search tree from max-heap will take O(nlogn) time.

So, option (B) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!