Open In App

Data Structures | Heap | Question 9

Like Article
Like
Save
Share
Report

What are the necessary condition for a Tree to be a heap?

(A)

the tree must be complete.

(B)

Every Root value is greater or smaller than the children’s value.

(C)

Both A and B

(D)

None



Answer: (C)

Explanation:

A Heap is a special Tree-based data structure in which the tree is a complete binary tree.

Types of Heap Data Structure

Generally, Heaps can be of two types:

  1. Max-Heap: In a Max-Heap the key present at the root node must be greatest among the keys present at all of its children. The same property must be recursively true for all sub-trees in that Binary Tree.
  2. Min-Heap: In a Min-Heap the key present at the root node must be minimum among the keys present at all of its children. The same property must be recursively true for all sub-trees in that Binary Tree.

 

Hence Option(C) is the correct answer.
 


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads