Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

supplementary code: (not a question)

header:

image text in transcribed

main:

image text in transcribed

image text in transcribed

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

What are their resources?

Answered: 1 week ago

Question

3. Is IBMs program really a mentoring program? Why or why not?

Answered: 1 week ago