Menu

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

NEED HELP ON D AND E.

5. (16 points) For each C++ function below, give the tightest asymptotic upper bound that you can determine for the functionint uglysweater(int n) { int j=0; for (int k = 2; k <= mushygingerbread(n); k+=2) { j++; cout << I am having so much fun witint lumpycoal(int n) { int s = 0; for (int k = 3; k <= n; k++) { int g = regiftedsocks (k); int h = regiftedsocks (k-1); s =

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): int uglysweater(int n) { int j=0; for (int k = 2; k <= mushygingerbread(n); k+=2) { j++; cout << “I am having so much fun with asymptotics!” << endl; return j; Return value for (d): Running time of (d): int lumpycoal(int n) { int s = 0; for (int k = 3; k <= n; k++) { int g = regiftedsocks (k); int h = regiftedsocks (k-1); s = s + (g / h); cout << “It’s the most wonderful homework of the year!” << endl; return mushygingerbread (s); Return value for (e): Running time of (e): 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