Question: THE PROGRAM MUST BE IN JAVA 1.You should do the problem with stacks to solve the problem 2.You are not supposed to use java libraries.

THE PROGRAM MUST BE IN JAVA

1.You should do the problem with stacks to solve the problem

2.You are not supposed to use java libraries. You need to implement your own data

structures to solve the problems.

 THE PROGRAM MUST BE IN JAVA 1.You should do the problem

Please I need help

There is a bag-like data structure, supporting two opcrations: Throw an element x into the bag Take out an clement from the ba Given a sequence of operations with return values, you're going to guess the data structure. It a stack Last-In. First-Out), a queue (Pirst-In, First-Out) a priority-queue (Always take out larg elements first) or something else that you can hardly imagine! Input There are several test cases. Each test case begins with a line conta ning a single mteger n (1 T 1000. Each of the next lines is either a type-1 command, or an integer 2 followed by an integer That means after executing a type-2 command, we get an element z without error. The value of is always a positive integer not larger than 100. The input is terminated by end-of-file (EOF). Output For each test case, output one of the following: It's definitely a stack. It's definitely a queue It's defiitely a priority queue It can't be a stack, a queue or a priority queue It can be more than one of the three data structures men- tioned above stack eue riority que eue impossible not sure Sample Input 1 2 1 3 2 3 1 2 2 3 7 1 2 1 3 2 5 1 4 2 4 Sample Output queue not sure impossible stack priority queue There is a bag-like data structure, supporting two opcrations: Throw an element x into the bag Take out an clement from the ba Given a sequence of operations with return values, you're going to guess the data structure. It a stack Last-In. First-Out), a queue (Pirst-In, First-Out) a priority-queue (Always take out larg elements first) or something else that you can hardly imagine! Input There are several test cases. Each test case begins with a line conta ning a single mteger n (1 T 1000. Each of the next lines is either a type-1 command, or an integer 2 followed by an integer That means after executing a type-2 command, we get an element z without error. The value of is always a positive integer not larger than 100. The input is terminated by end-of-file (EOF). Output For each test case, output one of the following: It's definitely a stack. It's definitely a queue It's defiitely a priority queue It can't be a stack, a queue or a priority queue It can be more than one of the three data structures men- tioned above stack eue riority que eue impossible not sure Sample Input 1 2 1 3 2 3 1 2 2 3 7 1 2 1 3 2 5 1 4 2 4 Sample Output queue not sure impossible stack priority queue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!