Tuesday, November 19, 2024
Google search engine
HomeData Modelling & AIData Structures | Heap | Question 9

Data Structures | Heap | Question 9

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

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Recent Comments