Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Find the number of times f() is called as a function of the input size n.
- a. for (i = n; i > 1; i /= 2)
- f()
- b. for (i = 0; i * i < n; i++)
- f()
- c. for (i = 0; i < n; i++)
- for (j = 0; j < 256; j++)
- f()
- d. for (i = 1; i <= n * n - 10; i++)
- for (j = 1; j <= i; j ++)
- f()
- e. for (i = 1; i <= n; i++)
- for (j = 1; j <= i; j++)
- for (k = 1; k <= j; k++)
- f()
- f. for (i = 1; i <= n; i++)
- for (j = 1; j < i; j *= 2)
- f()
- g. for (i = 1; i <= n; i++)
- for (j = 1; j <= n; j += i)
- f()
- h. void compute(int n)
- if (n == 0) return;
- for (int i = 0; i < n; i++)
- f()
- compute(n/2)
- compute(n/2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement