Question: package student; import java.util.Collection; public class StackDS { /** * Appends the specified element to the end of this DS. * @param e */ public
package student; import java.util.Collection; public class StackDS{ /** * Appends the specified element to the end of this DS. * @param e */ public void add(E e){ } /** * Inserts the specified element at the specified position in this DS. * @param index * @param element */ public void add(int index, E element){ } /** * Appends all of the elements in the specified collection to the end of * this DS, in the order that they are held by the specified collection. * @param c * @return */ public void addAll(Collection extends E> c){ } /** * Inserts all of the elements in the specified collection into this list * at the specified position. * @param index * @param c * @return */ public void addAll(int index, Collection extends E> c){ } /** * Removes all of the elements from this DS. */ public void clear(){ } /** * Returns true if this DS contains the specified element. * @param o * @return */ public boolean contains(Object o){ return false; } /** * Returns true if this list contains all of the elements of the specified * collection. * @param c * @return */ public boolean containsAll(Collection> c){ return false; } /** * Returns the element at the specified position in this DS. * @param index * @return */ public E get(int index){ return null; } /** * Returns the index of the first occurrence of the specified element in * this DS, or -1 if this list does not contain the element. * @param o * @return */ public int indexOf(Object o){ return 0; } /** * Returns true if this list contains no elements. * @return */ public boolean isEmpty(){ return false; } /** * Removes the element at the specified position in this DS. * @param index * @return */ public E remove(int index){ return null; } /** * Removes the first occurrence of the specified element from this DS, * if it is present. * @param o * @return */ public void remove(Object o){ } /** * Removes from this DS all of its elements that are contained in the * specified collection. * @param c * @return */ public void removeAll(Collection> c){ } /** * Retains only the elements in this DS that are contained in the specified * collection. * @param c * @return */ public void retainAll(Collection> c){ } /** * Replaces the element at the specified position in this DS with the * specified element. * @param index * @param element * @return */ public void set(int index, E element){ } /** * Returns the number of elements in this DS. * @return */ public int size(){ return 0; } /** * You only need to implement this function if this is Queue or a Stack else throw * UnsupportedOperationException * * * Queue: * Retrieves, but does not remove, the head of this queue, or returns null if this * queue is empty. * * * Stack: * Looks at the object at the top of this stack without removing it from the stack. */ public E peek(){ return null; } /** * Retrieves and removes the head of this queue, or returns null if this queue * is empty. * * You only need to implement this function if this is Queue else throw * UnsupportedOperationException * @return */ public E poll() { return null; } /** * You only need to implement this function if this is Queue or Stack else throw * UnsupportedOperationException * * Retrieves and removes the head of this queue or the top of the stack. */ public E remove(){ return null; } /** * You only need to implement this function if this is Stack else throw * UnsupportedOperationException * * Removes the object at the top of this stack and returns that object as the * value of this function. * @return */ public E pop(){ return null; } /** * You only need to implement this function if this is Stack else throw * UnsupportedOperationException * * Pushes an item onto the top of this stack. * @param item */ public void push(E item){ } }
==============================
use Linklist
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
