Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Iterator; public class ThreeTenStack { //storage - you MUST use this for credit! //Do NOT change the name or type //NOTE: you cannot use

import java.util.Iterator;

public class ThreeTenStack {

//storage - you MUST use this for credit! //Do NOT change the name or type //NOTE: you cannot use any arrays or JCF instances in your implementation. private ThreeTenDLList elements; // ADD MORE PRIVATE MEMBERS HERE IF NEEDED! // initialize the ThreeTenStack to being an empty ThreeTenStack public ThreeTenStack() {

}

public void push(T item) { //push an item onto the ThreeTenStack //you may assume the item is not null //O(1)

} public T pop() { //pop an item off the ThreeTenStack //if there are no items on the ThreeTenStack, return null //O(1) //default return, remove or update as needed return null;

} public T peek() { //return the top of the ThreeTenStack (but don't remove it) //if there are no items on the ThreeTenStack, return null //O(1) //default return, remove or update as needed return null;

}

public String toString() { //Create a string of the ThreeTenStack where each item //is separated by a space from bottom to top, that is: // - the bottom of the ThreeTenStack should be shown to the left; and // - the top of the ThreeTenStack should be shown to the right //Hint: Reuse the provided code from another class //instead of writing this yourself! //O(n) where n is the number of items in stack //default return, remove or update as needed return null;

} public boolean isEmpty() { //return whether or not the ThreeTenStack is empty //O(1) //default return, remove or update as needed return false;

}

public ThreeTenStack reverseStack(){ //return a new stack with all items from this stack // but in the reverse order // i.e. current stack top should be at the bottom of the reversed stack // current stack bottom should be at the top of the reversed stack // // Note: the returned new stack should not be affected by any // subsequent operations of this stack. See examples below in main(). // O(n) where n is the number of items in stack //default return, remove or updated as needed 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_2

Step: 3

blur-text-image_3

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

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions

Question

i need 1 2 5 8

Answered: 1 week ago