Add another option for c heapsort, minor refactors, update docs
This commit is contained in:
11
c/test.c
11
c/test.c
@@ -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;
|
||||
|
Reference in New Issue
Block a user