Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ m/courses/2656158/assignments/24348898 ssignments > black box black box Imagine a black box data structure - you can push data into it and pop data

image text in transcribed
image text in transcribedin c++
m/courses/2656158/assignments/24348898 ssignments > black box black box Imagine a "black box" data structure - you can push data into it and pop data out, but you cannot look at the implementation. Write a program that will consider an input series of push commands and expected pop values, then report on the nature of the black box structure. It might be a stack, a queue, a priority queue (with rank value), or none of these; you may also find that the push/pop data is insufficient to determine the type of structure. You may use the implementations in "p2queue.h", "p2priorityqueue.h", and "p2stack.h" Your program should run like these examples. Command: Commands US Command: PUSH Command: POP 9 Command: POP3 Command: POP 5 Comand: EN The black box holds a stack In this first example, we can see that 5,3,9 are pushed into the box and then 9,3,5 are popped out - clearly this is the First In, Last Out behavior we expect in a stack. Sometimes, however, it may be unclear, as in the next example, Comand: PUSH RUSH 2 C Cod: POP 2 Cod: POP Next Previous 10:17 AM AD 20 ments > black box black box Comand: FUSH Command: FUSH Command: FCF Command: POP3 Command: FCP 1 Command: The black box remains mysterious. In the second example, the data we see are not enough to firmly identify what's in the box - it could be a stack or a priority queue. Or the data we see might not match the expected behavior of any of the three data structures, as in the next example. Command: PUSH Comand: USA Command:PUSH 35 Command: POP 35 Command: POP 12 Command: POP A6 Command: END The black box holds something else. Submit Source code: Choose File No file chosen Submit Next - Previous 10:17 AM A $ N o te G D 2/10/2020

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions