Answered step by step
Verified Expert Solution
Link Copied!

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, 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.
image text in transcribed

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 Systems For Advanced Applications 18th International Conference Dasfaa 2013 Wuhan China April 22 25 2013 Proceedings Part 2 Lncs 7826

Authors: Weiyi Meng ,Ling Feng ,Stephane Bressan ,Werner Winiwarter ,Wei Song

2013th Edition

3642374492, 978-3642374494

More Books

Students also viewed these Databases questions

Question

2. Are my sources up to date?

Answered: 1 week ago