Question: USING C PROGRAMING Converting a standard queue to a priority queue. Modify structure of a queuenode to contain the integer data, integer priority, and pointer

USING C PROGRAMING
Converting a standard queue to a priority queue.
Modify structure of a queuenode to contain the integer data, integer priority, and pointer to next
queuenode structure
Modify program to prompt for priority in addition to the data to be added
There are no changes in initializing, empty/full checking, or fetching.
Modify Add prototype, call, and definition to include the priority to add as a parameter
Within the add subroutine
allocate memory for a new node
put data and priority in it
Consider the following scenarios for adding the new node:
adding to empty queue (front and back both NULL)
set new node's next to NULL
set both front and back to the new node
adding to the back of the queue (new node's priority back node's priority)
set new node's next to NULL
set back node's next to new node
move back to new node
adding to the front of the queue (new node's priority > front node's priority)
set new node's next to front node
move front to new node
adding to the middle of the queue
set temp to front node
while new node's priority is temp's next node's priority
move temp to temp->next
once the loop is finished, set new node's next to temp's next
move temp's next to new node You are to prepare a program that will provide you with a menu to manipulate a priority queue.
Your program should allow you to add to a priority queue, delete from a priority queue, list the
contents of the priority queue, and quit.
The priority queue should be able to contain integer data. A priority of 1 is the lowest priority
and should be added at the back of the queue.
 USING C PROGRAMING Converting a standard queue to a priority queue.

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!