Menu
Coddy logo textTech

Final Challenge #1

Lesson 8 of 9 in Coddy's Heap Sort - DSA Series course.

challenge icon

Challenge

Medium

Time to put a twist on Heap Sort.

Modify your heapSort function so it sorts the array in descending order (from largest to smallest) and returns it.

Hint: build a min-heap instead of a max-heap. Then each extraction moves the smallest remaining value to the end, so the array fills up largest-to-smallest.

Try it yourself

#include <stdlib.h>

int* heapSort(int* arr, int arr_size, int* returnSize) {
    // Write code here
    *returnSize = arr_size;
    return arr;
}

All lessons in Heap Sort - DSA Series