not getting the correct output for this case.
Max heap in o(n) implementation
@guptashubham210a
I am not understanding your doubt. The heap has been constructed properly. All the parent nodes are greater than their child nodes. Can you please elaborate your query?
@guptashubham210a
You are mistaken. A heap is not a sorted array. It outputs elements in a sorted array. A max heaps property is that all the child nodes of a node are smaller than the parent nodes. The children are represented by 2i and 2i + 1. In the previous output, you can clearly see that the property holds out.
If my answer is able to resolve your query, please mark the doubt as resolved.