Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following: public void mystery2(int n) { if(n <= 1) System.out.print(n

ID: 3608674 • Letter: G

Question

Given the following: public void mystery2(int n) {    if(n <= 1)       System.out.print(n);    else    {       mystery2(n/2);       System.out.print(", "+ n);    } } What is printed by the method call: [a]mystery2(1)________ [b]mystery2(2)_______ [c]mystery2(3)________ [d]mystery2(4)_________ [e]mystery2(16)________ [f]mystery2(30)_________ [g]mystery2(100)__________ [h]how many times will mystery2 be called by the callmystery2(1000)?______ Given the following: public void mystery2(int n) {    if(n <= 1)       System.out.print(n);    else    {       mystery2(n/2);       System.out.print(", "+ n);    } } What is printed by the method call: [a]mystery2(1)________ [b]mystery2(2)_______ [c]mystery2(3)________ [d]mystery2(4)_________ [e]mystery2(16)________ [f]mystery2(30)_________ [g]mystery2(100)__________ [h]how many times will mystery2 be called by the callmystery2(1000)?______

Explanation / Answer

b) 1, 2 c) 1, 3 d) 1, 2, 4 e) 1, 2, 4, 8, 16 f) 1, 3, 7, 15, 30 g) 1, 3,6,12, 25,50,100 h) It will recurse down 1000, 500, 250, 125, 62, 31, 15, 7, 3,1 so the initial call will call it 9 more times (a total of 10including the original call to mystery2(1000)
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote