Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) The purpose of this assignment is to gain experience: in using heaps to implement priority queues, in developing command-driven applications, and, in designing a

1) The purpose of this assignment is to gain experience: in using heaps to implement priority queues,

in developing command-driven applications,

and, in designing a robust program test suite.

We will implement a simple priority queue system, based on a min/max heap. You will implement your heap using aat array (probably with elements of some structured type), an write your own "push" (add element) and "pop" (removeelement) routines. The intent of this exercise is to learn how heaps work by understanding how to build them. The use of vectors or other containers which provide push and pop primitives will result in a score of 0 for thisassignment. Programs will be written in C++ in the stdlinux environment, using the text editor of your choice and the "g++"compiler. Programs will be written to read from standard input and write to standard output.

2) input/ output format

image text in transcribed

Each input le will consist of priority queue commands, one such command on each line.

Supported commands and command formats are given in table 1 above.

All command numbers appearing in input les will be integer values 1 through 6 inclusive.

No invalid command numbers will appear in the data.

all input commands will be syntactically valid.

3) program function

As the queue commands are processed, you should: count the overall total number of commands which appear in the le.

the rst command in the le is dened as "command number 1", the second as "command number 2," andso forth.

count all input commands, whether valid or invalid, in your total command count.

for each command type, count the number valid commands

for the individual commands, the rst "pop" command (for example) would be "pop command number 1," the

next "pop" command "pop command number 2," and so forth.

count only valid commands in the totals of each individual command type.

For example, if a test le contained only 100 add element commands, and 10 of them were semantically invalid, then thetotal command count would be 100, while the total add element commands processed would be 90.

image text in transcribed

Table 2 provides the actions to be performed and the output to be generated for each queue command.

In all cases, you should perform any appropriate heap functions as needed.

Input data les will be syntactically well formated (no character data, missing or extra parameters, etc.), but may not besemantically correct (e.g. you may be asked to delete a node that doesnt exist, or add one that is already in the queue).You should appropriately report any instance of a semantically incorrect command. Use the format: Cannot where the variables have the following possible values:

image text in transcribed

image text in transcribed

command 1 add element 2 delete element 3 reset priority 4 read (query top element) 5 pop (remove top element) 6 finalize (print and remove all current queue contents) format knew priority Table 1: input command formats command 1 add element 2 delete element 3 reset priority 4 read (query top element) 5 pop (remove top element) 6 finalize (print and remove all current queue contents) format knew priority Table 1: input command formats

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_2

Step: 3

blur-text-image_3

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

=+a) Find the z-score of the observed proportion.

Answered: 1 week ago

Question

=+ Have they changed the way employers view IP?

Answered: 1 week ago