logo CodeStepByStep logo


Language/Type: C++ recursion
Author: Marty Stepp (on 2016/06/16)

For each call to the following recursive function, write the output that is produced as it would appear on the console. Hint: To avoid re-tracing out long chains of calls, it may help you to look at your own notes on call results that you have already previously computed, and re-use those results as applicable.

void recursionMystery8(int n) {
    if (n <= 1) {
        cout << n;
    } else {
        cout << n << " = (";
        recursionMystery8(n / 2 + n % 2);
        cout << ", ";
        recursionMystery8(n / 2);
        cout << ")";

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.