Menu

5 16 Points C Function Give Tightest Asymptotic Upper Bound Determine Function S Runtime T Q43889072

5. (16 points) For each C++ function below, give the tightest asymptotic upper bound that you can determine for the function(c) int leftovercandy cane(int n) { int p = 0; int q = 0; while (p < 18 * n * n) { if (p % 2 == 0) { q++; p++; for (int r = 1

5. (16 points) For each C++ function below, give the tightest asymptotic upper bound that you can determine for the function’s runtime, in terms of the input parameter. Where prompted, also compute the return value of the function. Express both runtime and return value in simplest terms. For all function calls, assume that the input parameter n > 1. (a) int regiftedsocks (int n) { int k = n; int x = 1; for (int w = 1; w<n; w++) { for (int y = w; y < 73550; y = y* 2) { x = x + W; } k = k * w; return k; Return value for (a): Running time of (a): int mushygingerbread (int n) { int r = 0; for (int i = 1; i *i < 16*n*n; i++) r = r + i; return r; Return value for (b): Running time of (b): (c) int leftovercandy cane(int n) { int p = 0; int q = 0; while (p < 18 * n * n) { if (p % 2 == 0) { q++; p++; for (int r = 1; r <q; r = r * 3) { q++; return p * q; Return value for (c): Running time of (c): Show transcribed image text 5. (16 points) For each C++ function below, give the tightest asymptotic upper bound that you can determine for the function’s runtime, in terms of the input parameter. Where prompted, also compute the return value of the function. Express both runtime and return value in simplest terms. For all function calls, assume that the input parameter n > 1. (a) int regiftedsocks (int n) { int k = n; int x = 1; for (int w = 1; w

Expert Answer


Answer to 5. (16 points) For each C++ function below, give the tightest asymptotic upper bound that you can determine for the func…

OR