Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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, emptyfull 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 tempnext
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 is the lowest priority
and should be added at the back of the queue.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started