1b) How many basic steps need to be done to execute a program above (in question 1a) with n = 2 (count only print statements) Answer?

icon
Related questions
Question
1b) How many basic steps need to be done to execute a program above (in question 1a) with n = 2 (count only print statements) Answer?
1a) What is the output of the following program?
void bar (int n)
{
if (n == 1) System.out.println("Hello");
else {
bar (n - 1);
System.out.println(n);
bar (n - 1);
}
}
void main() {
bar(3);
}
Output:
Transcribed Image Text:1a) What is the output of the following program? void bar (int n) { if (n == 1) System.out.println("Hello"); else { bar (n - 1); System.out.println(n); bar (n - 1); } } void main() { bar(3); } Output:
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer