Practice · 2 of 4
Array Binary Heap
CHALLENGE
Difficulty: advanced+25 XP
Min-heap over a fixed int array:
``c
typedef struct { int a[64]; size_t n; } heap_t;
void heap_push(heap_t *h, int v);
int heap_pop(heap_t *h); /* returns min; caller ensures n>0 */
int heap_min(const heap_t *h);
``
push appends and sifts up; pop swaps the root with the last, shrinks, sifts down.
Press Submit to check your solution.
Back to lesson: Practice: Data Structure Build Drills