Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following code: static void showOutput ( int mark ) { if ( mark = = 0 ) { System.out.print ( *

Given the following code:
static void showOutput(int mark){
if (mark ==0){
System.out.print("*");
}
else {
System.out.println("[");
showOutput(mark -1);
System.out.print(",");
showOutput(mark -1);
System.out.println("]");
}
}
Can you determine what is produced by the following subroutine calls:
showOutput(0), showOutput(1), showOutput(2), and showOutput(3)?
a.
showOutput(0) outputs: *
showOutput(1) outputs: [*,*]
showOutput(2) outputs: [[*,*],[*,*]]
showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]]
b.
showOutput(0) outputs: [
showOutput(1) outputs: *,*
showOutput(2) outputs: [[],[]]
showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]]

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

More Books

Students also viewed these Databases questions