1.

What is a heap data structure?

Answer»

Heap is a special tree-based non-linear data structure in which the tree is a complete binary tree. A binary tree is said to be complete if all levels are completely filled except possibly the last level and the last level has all elements as left as possible. Heaps are of two types:



  • Max-Heap:

    • In a Max-Heap the data element present at the root node must be the greatest among all the data elements present in the tree.

    • This property should be recursively true for all sub-trees of that binary tree.




  • Min-Heap:

    • In a Min-Heap the data element present at the root node must be the smallest (or minimum) among all the data elements present in the tree.

    • This property should be recursively true for all sub-trees of that binary tree.






Discussion

No Comment Found