0
2.4kviews
What is heap? Sort the following numbers using heap sort. 67, 12, 89, 26, 38, 45, 22, 79, 53
1 Answer
0
32views
  1. A heap is a special kind of tree-based data structure.
  2. A heap is a complete binary tree in which every node satisfies the Heap property which states that: “The node_value(A) ≥ node_value(B) where B is a Child of A”
  3. This means that at elements at every node will be having a value greater than or equal to its parent element. That means, the root node will be having the highest value in the tree.
  4. Such kind of tree is popularly called as max-heap.
  5. A tree which works in exactly the opposite fashion of the above mentioned property is called as min-heap.
  6. The root element of a min-heap will be having the lowest value.
  7. Consider the array " 67, 12, 89, 26, 38, 45, 22, 79, 53"

Step 1: Build a heap using elements of array

enter image description here

Step 2:Repeatedly delete the Root element of the heap created

enter image description here

Please log in to add an answer.