Init commit, initial version of c heap-sort for generic types

This commit is contained in:
2025-10-06 17:45:39 -05:00
commit 095ba92914
6 changed files with 157 additions and 0 deletions

12
c/algorithms/sort_heap.c Normal file
View File

@@ -0,0 +1,12 @@
#include "../data_structures/heap.h"
#include "sort_heap.h"
void dlos_sort_heap(dlos_Heap *h) {
int original_size = h->size;
for (int i = h->size - 1; i > 0; i--) {
dlos_node_swap(h->arr, 0, i);
h->size -= 1;
dlos_sift_down(0, h);
}
h->size = original_size;
}

5
c/algorithms/sort_heap.h Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
#include "../data_structures/heap.h"
void dlos_sort_heap(dlos_Heap *h);