28 lines
699 B

#include <stdbool.h>
struct PriorityQueue {
int* array;
// The NEXT item to be added
size_t max_item;
size_t size;
typedef struct PriorityQueue PriorityQueue;
void insert(PriorityQueue *priority_queue, int item);
int extract (PriorityQueue *priority_queue);
size_t parent (size_t index);
size_t l_child (size_t index);
size_t r_child (size_t index);
void bubble_up (PriorityQueue *priority_queue, size_t index);
void bubble_down (PriorityQueue *priority_queue, size_t index);
void print_queue (PriorityQueue *priority_queue);
void swap_parent (PriorityQueue *priority_queue, size_t lower_index);
bool compare (PriorityQueue *priority_queue, size_t first_index, size_t second_index);