Building heap from array

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.

Hello @div_yanshu07 yes you are right.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.