Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the output of the following program? ( 4 Marks ) StackPT stk 1 = new ArrayStackPT ( 8 ) : StackPT stk 2

What is the output of the following program?
(4 Marks)
StackPT stk 1= new ArrayStackPT (8) :
StackPT stk2= new ArrayStackPT (8) :
StackPT stk3= new ArrayStackPT (8):
StackPT stk4= new ArrayStackPT (8):
QueuePT q1= new ArrayQueuePT(8);
int n=30;
while
stk1.push (n%4+1);
n=n4;
String result =n;
while (Istk1.isEmpty())
result += stk1.pop ()+";
System.out.println("the optput of stk1 : "+result); //
for(int i=0;i8;i++)
stk3.push(i*5);
stk2.push(stk3.pop()*2);
stk2.push(stk3.pop())*2;
stk2.push(stk3.pop())*2;
result =?in;
while (!stk2.isEmpty()){
result += stk2.pop ()+";
}
System.out.println("the optput of stk2: "+result); //.
for(int i=0;i8;i++
{
if(i%4==0)
stk4.push(i+(int)stk3.pop());
}
result ="';
while (!stk4.isEmpty())
result +=stk4.pop()+"";
}
System.out.println("the optput of stk4 : "+result); //
int limit =5;
for (int i=0;i limit; i++){
q1.enqueue((int)Math.pow(i, i));
}
result ="';
while (!q1.isEmpty())
result += q1.dequeue()+"";
}
System.out.println("the optput of q1: "+result); //
}
}
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions