Question: C PROGRAMMING ONLY Please write down code for part that says //fix this supplementary code: (not a question) header: main: #include #include #include pri_queue.h. /**

C PROGRAMMING ONLY

Please write down code for part that says //fix this

C PROGRAMMING ONLY Please write down code for part that says //fix

supplementary code: (not a question)

header:

this supplementary code: (not a question) header: main: #include #include #include "pri_queue.h".

main:

/** @file pri_queue.c */ static Node_ptr_t head = NULL; Insert a Node

into a priority queue. * @param priority @param data @author YOUR NAMX

#include #include #include "pri_queue.h". /** @file pri_queue.c */ static Node_ptr_t head = NULL; Insert a Node into a priority queue. * @param priority @param data @author YOUR NAMX void PQ_Insert(int priority, char * data) { //FIX THIS } Delete and return the node with the highest priority. @return The highest priority Node. Node_ptr_t PQ_delete() { //FIX THIS return NULL; */ Do NOT modify this function. @return A pointer to the head of the list. (NULL if list is empty.) Node_ptr_t PQ_get_head 0{ return head; } Do NOT modify this function. @return the number of items in the queue int PQ_get size(){ int size 0; for(Node_ptr_t tmp head; tmp != NULL; tmp tmp->next, size++) return size; #ifndef PRI_QUEUE_H #define PRI_QUEUE_H typedef struct node { int priority; char * data; struct node * next; } Node_t, * Node_ptr_t; extern void PQ_insert( int, char *); extern Node_ptr_t PQ_delete(); extern Node_ptr_t PQ_get_head(); extern int PQ_get_size(); #endif /* PRI_QUEUE_H */ #include #include #include #include "pri_queue.h" /* DO NOT MODIFY THIS FILE */ int main(int argc, char** argv) { Node_ptr_t head; assert (PQ_get_size() == 0); fprintf(stderr, "First assert worked! "); PQ_insert(0, "first node"); assert(PQ_get_size() == 1); fprintf(stderr, "Second assert worked! "); head = PQ_get_head(); assert (head != NULL); fprintf(stderr, "Third assert worked! "); assert (head->data == "first node"); fprintf(stderr, "Fourth assert worked! "); assert (head->priority == 0); fprintf(stderr, "Fifth assert worked ! "); PQ_insert(5, "abc"); head = PQ_get_head(); assert (head->priority == 5); fprintf(stderr, "Sixth assert worked ! "); assert (head->next->priority 0); fprintf(stderr, "Seventh assert worked ! "); PQ_insert(3, "def"); head = PQ_get_head(); assert (head->priority == 5); fprintf(stderr, "Eigth assert worked ! "); assert (head->next->priority == 3); fprintf(stderr, "Ninth assert worked ! "); assert (head->next->next->priority == 0); fprintf(stderr, "Tenth assert worked ! "); PQ_insert(7, "hij"); head = PQ_get_head(); assert (head->priority == 7); fprintf(stderr, "11th assert worked! "); assert (head->next->priority == 5); fprintf(stderr, "12th assert worked! "); assert (head->next->next->priority == 3); fprintf(stderr, "13th assert worked ! "); assert (head->next->next->next->priority 0); fprintf(stderr, "14th assert worked ! "); PQ_insert(2, "par"); head = PQ_get_head(); assert (head->priority == 7); fprintf(stderr, "15th assert worked! "); assert (head->next->priority == 5); fprintf(stderr, "16th assert worked! "); assert (head->next->next->priority == 3); fprintf(stderr, "17th assert worked! "); assert (head->next->next->next->priority 2); fprintf(stderr, "18th assert worked! "); assert (head->next->next->next->next->priority fprintf(stderr, "19th assert worked! "); 0); return (EXIT_SUCCESS); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!