Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NO INFINTE LOOPS /** * initialize array to an empty array and sizeto 0 */ public Stack() { } /** * * @return if there

NO INFINTE LOOPS

/**
* initialize array to an empty array and sizeto 0
*/
public Stack() {
}

/**
*
* @return if there are no items currently onthe stack
* (note that the array may be of size 5 or 10or ... and still be empty)
*/
public boolean isEmpty() {
return false;
}

/**
*
* @return if no more items can be added to thestack.
* That is, the stack is at capacity
*/
public boolean isFull() {
return false;
}

/**
* increase the capacity of the stack by 5
*/
public void grow() {
}

/**
* add an item on "top" of the stack.
* For example, if the array is of length 10 andthere are 7 items on the stack,
* the item passed is added as the 8th item, andnow the stack size is 8.
* Note that nothing should be done if thepassed String is null.
* @param s
*/
public void push(String s) {
}

/**
*
* @return the top item (and remove it) from thestack.
* return null if stack is empty.
*/
public String pop() {
return null;
}

/**
*
* @return the top item without removing it fromthe stack.
* return null if stack is empty.
*/
public String top() {
return null;
}

/**
* @param idx: index of item to be removed
* @return the item at index idx from the stack.Assume that the index of the "bottom"
* item is 0, and the top item is size-1.
* return null if there is no item at passedindex.
*/
public String get(int idx) {
return null;
}

/**
* return a string representation of thestack.
* if the stack has items "Me" (at index 2),"fail" (at index 1),
* "English" (at index 0),
* the String returned should be"MeFailEnglish".
* Return "" if the stack is empty.
*/
public String toString() {
return null;
}
}

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

Business Statistics A Decision Making Approach

Authors: David F. Groebner, Patrick W. Shannon, Phillip C. Fry

9th Edition

013302184X, 978-0133021844

More Books

Students also viewed these Programming questions

Question

solve

Answered: 1 week ago