diff options
Diffstat (limited to 'heap.c')
| -rw-r--r-- | heap.c | 9 |
1 files changed, 7 insertions, 2 deletions
| @@ -122,6 +122,8 @@ my_heapsort(T a[], size_t n) | |||
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | // TODO: https://www.geeksforgeeks.org/how-to-check-if-a-given-array-represents-a-binary-heap/ | ||
| 126 | |||
| 125 | // ------------------------------------------- | 127 | // ------------------------------------------- |
| 126 | 128 | ||
| 127 | struct pq { // Priority Queue | 129 | struct pq { // Priority Queue |
| @@ -230,13 +232,16 @@ main(void) | |||
| 230 | { | 232 | { |
| 231 | test_heapsort(); | 233 | test_heapsort(); |
| 232 | test_pq(); | 234 | test_pq(); |
| 233 | #if 0 // Heap-Testprogramm | 235 | #if 1 // Heap-Testprogramm |
| 236 | // Beispiel aus "Informatik - Datenstrukturen und Konzepte der Abstraktion" | ||
| 237 | // Kapitel 5.10, Seite 372 ff. | ||
| 234 | T heap[20] = { 18, 18, 16, 9, 7, 1, 9, 3, 7, 5 }; | 238 | T heap[20] = { 18, 18, 16, 9, 7, 1, 9, 3, 7, 5 }; |
| 235 | 239 | ||
| 236 | print_heap(heap, 10); | 240 | print_heap(heap, 10); |
| 237 | 241 | ||
| 238 | //heap[10] = 13; fixup(heap, 10); | 242 | //heap[10] = 13; fixup(heap, 10); |
| 239 | swap(heap, 0, 9); fixdown(heap, 0, 9); | 243 | swap(heap, 0, 9); |
| 244 | fixdown(heap, 0, 9); | ||
| 240 | 245 | ||
| 241 | print_heap(heap, 9); | 246 | print_heap(heap, 9); |
| 242 | #endif | 247 | #endif |
