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

4. Consider the following functions defined recursively a. void Mysteryl (int N)

ID: 3717987 • Letter: 4

Question

4. Consider the following functions defined recursively a. void Mysteryl (int N) ( if (N1) System.out print (N) else f Answer System.out print (N) Myateryl (N-1) Myateryl (N-1)1 b. void Mystery2 (int N) f if (N else f 1) System.out.print (N) Answer Mystery2 (N-1) System.out.print (N) Mystery2 (N-1) c. void Mystery3 (int N) ( if (N 1) System.out.print (N) Answer else f Mystery3 (N-1); Mystery3 (N-1); system.out.print (N) double F1 (double x, int n) if (n 0) return 0; Answer else return x + F1 (x, n-1) double F2 (int n) ( if (n

Explanation / Answer

4 a) Output of Mystery1(4) = 432112113211211

Mystery1(4)

= 4 Mystery1(3) Mystery1(3)

= 4 3 Mystery1(2) Mystery1(2) 3 Mystery1(2) Mystery1(2)

= 4 3 2 Mystery1(1) Mystery1(1) 2 Mystery1(1) Mystery1(1) 3 2 Mystery1(1) Mystery1(1) 2 Mystery1(1) Mystery1(1)?

= 4 3 2 1 1 2 1 1 3 2 1 1 2 1 1

b) Output of Mystery2(4) = 121312141213121

Mystry2(4)

= Mystry2(3) 4 Mystry2(3)

= Mystry2(2) 3 Mystry2(2) 4 Mystry2(2) 3 Mystry2(2)

= Mystry2(1) 2 Mystry2(1) 3 Mystry2(1) 2 Mystry2(1) 4 Mystry2(1) 2 Mystry2(1) 3 Mystry2(1) 2 Mystry2(1)

= 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1

c) output of Mystry3(4) = 112112311211234

Mystry(4)

= Mystry(3) Mystry(3) 4

= Mystry(2) Mystry(2) 3 Mystry(2) Mystry(2) 3 4

= Mystry(1) Mystry(1) 2 Mystry(1) Mystry(1) 2 3 Mystry(1) Mystry(1) 2 Mystry(1) Mystry(1) 2 3 4

= 1 1 2 1 1 2 3 1 1 2 1 1 2 3 4

Do ask if any doubt. Please upvote.

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