Given the following: public void myst(int n) { if(n <= 0) System.out.print(\"*\"
ID: 3608641 • Letter: G
Question
Given the following: public void myst(int n){ if(n <= 0) System.out.print("*"); else if(n % 2 == 0) { System.out.print("("); myst(n - 1); System.out.print(")"); } else { System.out.print("["); myst(n - 1); System.out.print("]"); } } What is printed by the method call: a) myst(0)___________ b) myst(1)___________ c) myst(2)___________ d) myst(3)___________ e) myst(6)___________ Given the following: public void myst(int n)
{ if(n <= 0) System.out.print("*"); else if(n % 2 == 0) { System.out.print("("); myst(n - 1); System.out.print(")"); } else { System.out.print("["); myst(n - 1); System.out.print("]"); } } What is printed by the method call: a) myst(0)___________ b) myst(1)___________ c) myst(2)___________ d) myst(3)___________ e) myst(6)___________
Explanation / Answer
a) myst(0) = * b) myst(1) = [*] c) myst(2) = [*]) d) myst(3) = [([*])] e) myst(6) = ([([([*])])]) //here is trace of each call calling myst(0) nRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.