Question: Hi can you help me answer the following Data Structure and Algorithm Question using Java with step by step detailed solution and explanation? Thank you
Hi can you help me answer the following Data Structure and Algorithm Question using Java with step by step detailed solution and explanation? Thank you very much!


2. Assume we are using stack of integer from class Stack, which has the code of all methods defined in the following Java interface (class Stack also has a working default constructor) public interface MyStack public boolean isEmpty) public boolean isFull); public void makeEmpty); //Return data on top of stack. //Throw exception if the stack is empty public int top() throws Exception; //Remove data on top of stack. //Throw exception if the stack is empty. public void pop() throws Exception; //Add new data on top of stack. //Throw exception if the operation is somehow //unsuccessful public void push (int data) throws Exception; We are using stack in our own class TestStack, which is: Class TestStack Stack s public Stack oddNumbersOA II You have to write code for this method. You are to implement method oddNumbers which returns a new stack which has all odd numbers from s, and the numbers are in the same order from top to bottom) as they are on s. when the method finishes its execution, stack s must remain unchanged. For example, if the original data inside s is 4 6 Then the returned stack is interface. You are allowed to create primitive type variables. *You are not allowed to create non-primitive type variables, or any data structure, except Stack(s) a. (8 marks) Explain, with illustrated drawing of stack(s), the inner workings of oddNumbers0. Your explanation should be clear and step-by-step b. (8 marks) Write code for oddNumbers
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
