Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a priority queue. In particular, you are asked to simulate a waiting line that forms in front of a bank teller in a typical

Implement a priority queue. In particular, you are asked to simulate a waiting line that forms in front of a bank teller in a typical bank. Different customers have different priorities. A priority queue should support the following functions (you must build these functions):

Insert(S,x) inserts the element x into the set S.

Maximum(S) returns the element of S with the largest key.

Extract_Max(S) removes and returns the element of S with the largest key.

Your program should be based on a heap structure. The input must accept the different customers and their priorities (Customer Name and Customer Priority are two attributes that you must use). As an output, the program should produce a list of the customers based on their priorities (decreasing order). You may assume priorities are integers.

This is a sample output.txt file (spaces separating customer names (no space after final name)):

Alan Paul

... for this input file (one customer and priority per line in this format):

Paul : 2

Alan : 5

You can break ties in any order if their priorities are the same.

JAVA or C++

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

More Books

Students also viewed these Databases questions

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago