Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Yi index =-1; 9 S2 9 0 9 0 11 2 Refer to the following code, implement the method: public NumStack join(NumStack s) public class

image text in transcribedimage text in transcribed

Yi index =-1; 9 S2 9 0 9 0 11 2 Refer to the following code, implement the method: public NumStack join(NumStack s) public class NumStack implements Comparable{ ments compa private Integer[] data; public NumStack join(numstack s) joins DPYRIGHT two stack from the bottom of each stack, private int index; for example, s1[2,0, 9] and s2[9,0,9], IT public NumStack(int cap) { calling s1.join(s2) should return a data=new Integer[cap]; NumStack which contains[11,0,18], COPYRIGHT s1 Returned NumStack } top 18 public boolean isEmpty() { return index == -1; bottom * == -1;RIGHT } public boolean is Full() { return index==data.length -1; } If the two stacks have different sizes, public NumStack pop() { then we just push extra items from the if(!isEmpty()) data[index-- ]=null; larger size stack to the resulting stack. return this; For example, $1[8,0, -9] and s2[1], } calling $1.join(52) should return COPY public int size(){ NumStack as follows: return index+1; s1 Resulting stack (returned) public Integer top(){ PYRIGHT top -9 if(isEmpty()) return null; return data[index]; bottom 8 1 public NumStack push(int num) { COPYRIGHT if(index

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

Step: 3

blur-text-image

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

8 Learn what determines some trends in the overall economy

Answered: 1 week ago

Question

describe steps to deal effectively with staff member complaints

Answered: 1 week ago