Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write in c. Thank you A priority queue is a FIFO list, maintained in sorted priority order. For this assignment, keep the list in

image text in transcribedimage text in transcribed

Please write in c. Thank you

A priority queue is a FIFO list, maintained in sorted priority order. For this assignment, keep the list in ascending priority order (so that nodes having lower priority go in the front of the queue). Put your code in pqueue.netid.c and pqueue.netid.h Define these structs: typedef struct int id; char name[32] studentRecord; typedef struct PQueueStruct int priority void *data; struct PQueuestruct *next; PQueueNode; Implement the following functions int enqueue (PQueueNode*pqueue, int priority, void *data) void dequeue (PqueueNodepqueue) void *peek (PQueueNode *pqueue) void printQueue (PueueNode *pqueue, void (printFunction) (void)) int getMinPriority(PQueueNode *pqueue) int queueLength (PQueueNode *pqueue) void printStudentRecord(void data) (1) enqueue (PQueueNodetpqueue, int priority, void data) This will put the data in the priority queue in the correct place. If there is already one or more nodes in the list having the same priority as the data that you are enqueueing, then put the new node after all of the nodes having that priority. Return zero from this function. (2) void dequeue (PQueueNode *pqueue) Remove the front of the list and return the data from that list node. If the pqueue is empty, then return NULL. (3) void *peek (PQueueNode pqueue) Return the data from the first node in the pqueue. If the pqueue is empty, then return NULL The peek operation does not actually remove a node from the pqueue! (4) void printQueue(PQueueNode *pqueue, void (printFunction) (void*)) Print each the data from each node in the queue. (5) int getMinPriority(PQueueNode *pqueue) etun the pronty the h puee s my, eum 1 (6) int queueLength (PQueueNode *pqueue) Return the number of nodes in the pqueue. (7) void printstudentRecord(void data) Print an instance of StudentRecord as "%s %d", with the name field and id field. Passing a function as a parameter For an example of how to use a function as a parameter, see function-parameter.c on the course gitlab site

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 Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

Define co-ordination?

Answered: 1 week ago