Question: Modify the push implementation so it does not allow duplicate items in the stack. So, if the caller wants to push an item that is

 Modify the push implementation so it does not allow duplicate items

Modify the push implementation so it does not allow duplicate items in the stack. So, if the caller wants to push an item that is already in the stack, a simple message is displayed, nothing is pushed. Assume the object must have necessary functions to check equality. To anwer this question you must implement pushNoDuplicates(ltem t) method public class GenericStack { private Item[] a; private int top; // holds the items // number of items in stack // create an empty stack with given capacity public Genericstack(int capacity) { a = (Item[]) new Object[capacity]; // no generic array creation } public boolean isEmpty() { return top == 0; }

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!