Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Refer to the following code, implement the method: public NumStack join(NumStack s) public NumStack join (NumStack s) joins two stack from the bottom of each
Refer to the following code, implement the method: public NumStack join(NumStack s) public NumStack join (NumStack s) joins two stack from the bottom of each stack, for example, 51[2,0, 9] and s2[9,0,9], calling s1.join(s) should return a NumStack which contains(11,0,18], s1 s2 Returned NumStack 9 9 18 top bottom 2 9 11 public class NumStack implements Comparable{ private Integer[] data; private int index; public NumStack(int cap){ Yr data=new Integer[cap]; index =-1; } public boolean isEmpty(){ return index == -2;GHT } public boolean isFull() { return index==data. length -1; } public NumStack pop() { if(!isEmpty()) data[index-- ]=null; return this; } public int size() { El return index+1; } public Integer top() { if(isEmpty()) return null; return data[index]; public NumStack push(int num) { if(index
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