Practice ยท 2 of 2
Heapify & Heapsort
Two classic builds on the heap idea:
``c
/* transforms a[0..n) into a min-heap in place โ O(n) bottom-up heapify */
void heapify(long *a, size_t n);
/* sorts a[0..n) ASCENDING using a MAX-heap built in place:
heapify as max-heap, repeatedly swap root with end and shrink.
(Classic heapsort: max-heap gives ascending order in place.) */
void heapsort_asc(long *a, size_t n);
``
No extra arrays: both are in-place.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Heap Gym