From 6af11155551496fa173f96759f0f36774a0fb503 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 29 Nov 2020 15:53:19 +0100 Subject: altes Testprogramm aktiviert... --- heap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/heap.c b/heap.c index e2ca750..6ad3010 100644 --- a/heap.c +++ b/heap.c @@ -122,6 +122,8 @@ my_heapsort(T a[], size_t n) } } +// TODO: https://www.geeksforgeeks.org/how-to-check-if-a-given-array-represents-a-binary-heap/ + // ------------------------------------------- struct pq { // Priority Queue @@ -230,13 +232,16 @@ main(void) { test_heapsort(); test_pq(); -#if 0 // Heap-Testprogramm +#if 1 // Heap-Testprogramm + // Beispiel aus "Informatik - Datenstrukturen und Konzepte der Abstraktion" + // Kapitel 5.10, Seite 372 ff. T heap[20] = { 18, 18, 16, 9, 7, 1, 9, 3, 7, 5 }; print_heap(heap, 10); //heap[10] = 13; fixup(heap, 10); - swap(heap, 0, 9); fixdown(heap, 0, 9); + swap(heap, 0, 9); + fixdown(heap, 0, 9); print_heap(heap, 9); #endif -- cgit v1.3