Question
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
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.
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
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