Question: COSC 2 1 5 : Homework # 1 For each of the following questions, write a class named HW 1 Q < # > where
COSC : Homework #
For each of the following questions, write a class named HWQ# where
is your last name and # is the number of the question. For example, if I were
doing this assignment, my class for the first question would be named BerdikHWQ For each
question, use the Stack class that we wrote together to create your stacks. Do not use the
java.util.Stack implementation.
Each question is worth one point. You will receive one point for each question for which you
submit code that works properly and follows the instructions. If your code either does not work
at all or accomplishes the desired result but does not follow the instructions, you will receive no
points.
All four classes must be submitted on Canvas by the specified due date. Since your submissions
will be tested using the Stack class that we wrote together, you should not modify it and there
is no need for you to include it in your Canvas submission.
Reverse the order of elements on stack S using two additional stacks.
Reverse the order of elements on stack S using one additional stack and some additional
nonarray variables.
Transfer elements from stack S to stack S so that the elements from S are in the same
order as on S by using one additional stack.
Transfer elements from stack S to stack S so that the elements from S are in the same
order as on S by using no additional stack but only some additional nonarray variables. this is class stack.java class import java.util.ArrayList;
public class Stack
T storage new T;
private ArrayList storage new ArrayList;
public void pushT el
storage.addel;
public T pop
if isEmpty
return null;
else return storage.removestoragesize;
public T topEl
if isEmpty
return null;
else return storage.getstoragesize;
public void clear
storage.clear;
public boolean isEmpty
return storage.isEmpty;
public String toString
return storage.toString;
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
