IN THIS WE ARE CONVERTING ARRAY/VECTOR INTO HEAP IN (NLOGN) TIME,
WE CAN ALSO SORT OUR ARRAY IN (NLOGN) TIME , THEN WHY ARE WE DOING THIS?
BUILDING HEAP FROM ARRAY IN ((NLOGN) TIME
Hello @CODER_JATIN
The Heapalg orithm is widely used because of its efficiency. Heap sort works by transforming the list of items to be sorted into a heap data structure, a binary tree with heap properties.
The element of the heap is removed and inserted into the sorted list. The remaining sub-tree is transformed into a heap again. This process is repeated until no elements remain.
it is used because of its these properties:
Efficiency,Consistency,Memory usage is less .
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.