We have two approach for this problem right??
First approach- Iterative approach, in this approach we traverse from first element and look for it’s parent index and according to the type i.e max or min we do the changes. This takes o(NlogN) time right?
Second approach would be to start from first non-leaf node and call heapify function this would take o(n) time.
Please correct me if I am wrong.