Question

O BJP3 Self-Check 12.14: mystery5 Language/Type: 血Java recursion recursive tracing Whitaker Brand (on 2013/04/01) Author: For

these are right answer but i dont know how to do it, can u explain mystery5(12,9) and mystery5(128,343)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
mystery5(x=12, y=9)
        => As x and y both are greater than 0, last if else block is hit.
        => 100 * mystery5(1, 0) + 10 * 2 + 9
        
Now mystery5(1, 0)
        => As x is greater than 0, hence again last if-else block is hit.
        => 100 * mystery5(0, 0) + 10 * 1 + 0
        => 100 * 0 + 10 + 0 = 10
        
So, mystery5(12, 9) =
        => 100 * 10 + 10 * 2 + 9 = 1000 + 20 + 9 = 1029.
        
=======================================

Similarly:
mystery5(128,343)
        => 100 * mystery5(12, 34) + 10 * 8 + 3

mystery5(12, 34)
        => 100 * mystery5(1, 3) + 10 * 2 + 4
        
mystery5(1, 3)
        => 100 * mystery5(0, 0) + 10 * 1 + 3
        => 100 * 0 + 10 + 3 = 13

So, now, mystery5(12, 34) => 100 * 13 + 10 * 2 + 4 = 1324
So, now, mystery5(128, 343) => 100 * 1324 + 10 * 8 + 3 = 132483

please upvote as i explained very clearly.

Add a comment
Know the answer?
Add Answer to:
these are right answer but i dont know how to do it, can u explain mystery5(12,9)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 5.43 (10 pts) What does the following program do? #include <stdio.h> 3 unsigned int mystery Cuns...

    5.43 (10 pts) What does the following program do? #include <stdio.h> 3 unsigned int mystery Cuns igned int a, unsigned int b): // function prototype 5 int main(void) printf("%s". "Enter two positive integers: unsigned int x: I/ first integer unsigned int y: // second integer scanf("Su%u". &x, &y); "); 12 13 14 15 II Parameter b must be a positive integer 16 to prevent infinite recursion 7 unsigned int mystery Cuns igned int a, unsigned int b) 18 printf("The result...

  • I know I'm on the right path, but don't know where to continue from here. This is a C++ assignmen...

    I know I'm on the right path, but don't know where to continue from here. This is a C++ assignment Your job is to write that will display a calendar for any given month of a given year. The user will need to type the number of the month as an integer from 1 to 12 (1 is for January, etc.), and the year as a 4-digit integer. This assignment simply requires that your program make use of more than...

  • Can you explain how this code for the 8 Queens Problem works? It's in C++ In case you dont know w...

    Can you explain how this code for the 8 Queens Problem works? It's in C++ In case you dont know what the 8 Queens problem is, "The eight queens puzzle is the problem of placing eightchess queens on an 8×8 chessboard so that no two queensthreaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal." This is the code: #include <iostream> #include <cmath> using namespace std; bool ok(int q[], int c) {     ...

  • I know the right answers by using a compiler. However, can you please explain each step...

    I know the right answers by using a compiler. However, can you please explain each step and how you get the correct answer. Thank you in advance. Output: E = 1 F = 7 G = 11 H = 14 W = 5 X = 6 Problem 7 #include <iostream> #include <cmath> using namespace std; void F1(int,int,int,int&); void F2(int,int&,int&,int&); int main ( void ) { int E=1,F=2,G=3,H=4,W=5,X=6;    F1(E,F,G,H);    F2(E,F,G,H);    cout << "E = " << E <<...

  • i dont know how to do (b), the answer is on the second picture but i...

    i dont know how to do (b), the answer is on the second picture but i dont get why it is discounted back by (1+ke)^n insdead of (1+g)^n, thanks a lot! Ke denotes tge required rate of return for equity holders Problems Eo=3 Nano Technologies Ltd recently earned $3.00 per share and has a history of paying out 40% of earnings as dividends. This payout ratio is expected to continue in the foreseeable future. Also, Nano's earnings and dividends per...

  • please answer i dont know how to do this Saved 2. Line following information applies to...

    please answer i dont know how to do this Saved 2. Line following information applies to the questions displayed below. Eli owns an insurance office, while Olivia operates a maintenance service that provides basic custodial duties. For the month of May, the following transactions occurred. Olivia decides that she will need insurance for a one-day special event at the end of the month and May pays Eli $230 in advance. May 5 Olivia provides maintenance services to Eli's insurance offices...

  • please help asap!! i dont know how to do the graphs Graphical Determination of Rate Plot...

    please help asap!! i dont know how to do the graphs Graphical Determination of Rate Plot a graph (excel or sheets) of Total moles of SO consumed ("Y") vs. time ("x") for EACH solution. The slope of the line (A [3,0,?] /At) is the "rate" of each reaction. Submit a graph for each reaction with your post lab report 1. Rate of each solution: Solution 1 Solution 2 Solution 3 Solution 4 Total moles of 5,017 consumed Solution 1. Initial...

  • Hello, I am working on my final and I am stuck right near the end of...

    Hello, I am working on my final and I am stuck right near the end of the the program. I am making a Tic-Tac-Toe game and I can't seem to figure out how to make the program ask if you would like to play again, and keep the same names for the players that just played, keep track of the player that wins, and display the number of wins said player has, after accepting to keep playing. I am wanting...

  • This is due in a few hours I don't know if I did this correctly can you double check my code to see if my return statements are fine and I follow the instructions accurately. Thank you!!! Modify m...

    This is due in a few hours I don't know if I did this correctly can you double check my code to see if my return statements are fine and I follow the instructions accurately. Thank you!!! Modify my code if anything return statement seems misplaced or inaccurately called. Here is my code: int write_sudoku_board(const char file_name[ ], int board[9][9]) { int number; int i,j; int a = 9; FILE* fp = fopen("sudoku.txt", "w"); int count = 0; for(i =...

  • How can I make this compatible with older C++ compilers that DO NOT make use of...

    How can I make this compatible with older C++ compilers that DO NOT make use of stoi and to_string? //Booking system #include <iostream> #include <iomanip> #include <string> using namespace std; string welcome(); void print_seats(string flight[]); void populate_seats(); bool validate_flight(string a); bool validate_seat(string a, int b); bool validate_book(string a); void print_ticket(string passenger[], int i); string flights [5][52]; string passengers [4][250]; int main(){     string seat, flight, book = "y";     int int_flight, p = 0, j = 0;     int seat_number,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT