Add another option for c heapsort, minor refactors, update docs

This commit is contained in:
2025-10-08 00:08:46 -05:00
parent 3fcd09e7c0
commit 6d84849ce8
5 changed files with 70 additions and 28 deletions

View File

@@ -22,17 +22,10 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < test_size; i++) {
a[i].value = &data_storage[i];
}
dlos_Heap heap = {
.size = test_size,
.arr = a,
.arr_size = test_size,
.compare = compare_nodes
};
dlos_max_heap(&heap);
dlos_sort_heap(&heap);
dlos_heapsort_array(a, test_size, compare_nodes);
for (int i = 0; i < test_size; i++) {
if (i == 0) printf("sorted: ");
printf("%d, ", *((int*) heap.arr[i].value));
printf("%d, ", *((int*) a[i].value));
if (i == test_size - 1) printf("\n");
}
return 0;