Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi all, i am confused with part 2. I need to write 3 methods. anyone can help me with reverse methode and delete? PART I
Hi all,
PART I A Linked Stack Inplementation (see attached Liststack.java and StackADT.Java) Java has a Stack class that holds elements of type Object. However, many languages do not provide stack types, so it is useful to be able to define your own. File StackADT. Java contains an interface representing the ADT for stack of objects and Linkedstack.java contains a skeleton for a class that uses a linked list to implement this Interface. It depends on the Node class in Node.java. (This could also be defined as an inner class.) Fill in code for the following public methods: void push(Object val) int pop() boolean 1sEmpty boolean isFull() In writing your methods, keep in mind that in a linked implementation of a stack, the top of stack is always at the front of the list. This makes it easy to add (push) and remove (pop) elements. File StackTest.java contains a simple driver to test your stack. Save it to your directory, compile it, and make sure it works. ERRE PART II. Stack Manipulation (see StackTest.java) Sometimes its useful to define operations on an ADT without changing the type definition itself. For example, you might want to print the elements in a stack without actually adding a method to the Stack ADT (you may not even have access to it). To explore this, use either the Stack class provided by Java (in java.util) or one of the stack classes that you wrote in an earlier lab exercise and the test program StackTest.java. Add the following static methods to the StackTest class (the signature for these methods and declaration in StackTest assumes you are using a stack class named Stacka modify them to use the name of your class): void printStack(Stack s)SE"prints the elements in stacks from top to botton. When printStack returns, 5 should be unchanged. Stack reverseStack(Stack s"returns a new stack whose elements are backwards fron those in S. Again, s is unchanged. Stack removeElement(Stack s, int val) S"returns a new stack whose elements are the sane as those in s (and in the same order) except that all occurrences of val have been removed. Again, s is unchanged. Modify the main method to test these methods. Be sure you print enough information to see if they are working! art III. Postfix Evaluation [see attached PostfixEvaluator.java and PostfixEvaluatorTest.java) mplete the missing code for PostfixEvaluator.java class using the PostfixEvaluator Test.java to test your code i am confused with part 2. I need to write 3 methods. anyone can help me with reverse methode and delete?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started