Question: Assignment 2 Construct a stack S1 that looks like this: 20

Assignment 2 Construct a stack S1 that looks like this: 20 <--top of the stack 6 11 4 16 7 <-- bottom of the stack Write a method void Delete(int item) which will delete the item from the stack by creating a stack S2 and using Peeks, Pushes and Pops and when it finds the item at the top of S1, Pop it. Then Peek-Push-Pop from S2 to S1. Therefore S1 should be a stack without the item. Put your code into your StackArray.java file. I will test it, using S1 as the stack. I will have a main program to delete 4 and then delete 6 and print out S1. I will also test it by trying to delete 33, which isn't in the stack. Again, I'll print out the stack S1. 

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!