Question

Select all the valid asymptotic runtime bounds for the following function f2 in the worst case:...

Select all the valid asymptotic runtime bounds for the following function f2 in the worst case:
public static int f1 (int n) {
int x = 0;
for (int i = 0; i < n; i++) {
x++;
}
return x;
}

public static int f2 (int n) {
if (n <= 1) {
return 1;
}
return f1(n) + f2(n/2) + f2(n/2);
}
Θ(n^2)
O(n^2)
Θ(log(n))
Θ(log^2(n))
Θ(nlog(n))
Ω(n)
Ω(n^2)

0 0
Add a comment Improve this question Transcribed image text
Answer #1


O(n^2)
Θ(nlog(n))
Ω(n)

Add a comment
Know the answer?
Add Answer to:
Select all the valid asymptotic runtime bounds for the following function f2 in the worst case:...
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
  • What are the valid runtime bounds for the method mystery with respect to argument n? Select...

    What are the valid runtime bounds for the method mystery with respect to argument n? Select all that apply. public static int mystery(int n) { for (int i = 1; i < n; i = i + i) { for (int j = 0; j < i; j++) { for (int k = 0; k < n; k++) { f0(n); } } } return -1; } public static void f0(int n) { int[] arr = new int[200]; for (int i...

  • Which big-O expression best characterizes the worst case time complexity of the following code? public static...

    Which big-O expression best characterizes the worst case time complexity of the following code? public static int foo(int N) ( int count = 0; int i1; while (i <N) C for (int j = 1; j < N; j=j+2) { count++ i=i+2; return count; A. O(log log N) B. O(log N2) C. O(N log N) D. O(N2)

  • Please give explanation as well ma E. Asymptotic Analysis rays For these problems, you should give...

    Please give explanation as well ma E. Asymptotic Analysis rays For these problems, you should give a brief explanation as hws.txt. You should not use any fancy typesetting tools (like LaTeX, Word, etc.). Just submit a text file called hws.txt. You are not required to explain your solutions, but you are encouraged to do so. Provide simple and tight asymptotic bounds for each of the following. Here, "simple" means roughly "no unnecessary terms or constants' and "tight" means "either the...

  • What is the runtime of each method? Give answer in Θ(big Theta) notation as a function...

    What is the runtime of each method? Give answer in Θ(big Theta) notation as a function of n, give a brief explanation. A. public static int method1(int n){ int mid = n/2; for (int i = mid; i >= 0; i--) System.out.println(i); for (int i = mid + 1; i <= n; i++) System.out.println(i); return mid; } B. public static int method2(int n){ for (int i = n; i >= 0; i / 3){ System.out.println(i ); } return mid; }...

  • QUESTION 5 What is the worst-case complexity of line 10 of function bar? A. O(1) B....

    QUESTION 5 What is the worst-case complexity of line 10 of function bar? A. O(1) B. O(N) C. O(i) D. O(log N) E. O(sqrt N) F. O(A[i]) G. O(N sqrt N) H. O(N log N) I. O(N^2) J. O(i^2) K. None of the above QUESTION 6 What is the worst-case complexity of lines 8-11 of function bar? A. O(1) B. O(N) C. O(i) D. O(log N) E. O(sqrt N) F. O(A[i]) G. O(N sqrt N) H. O(N log N) I....

  • QUESTION 8 What is the worst-case complexity of line 7 of function bar? A. O(1) B....

    QUESTION 8 What is the worst-case complexity of line 7 of function bar? A. O(1) B. O(N) C. O(i) D. O(log N) E. O(sqrt N) F. O(A[i]) G. O(N sqrt N) H. O(N log N) I. O(N^2) J. O(i^2) K. None of the above QUESTION 9 What is the worst-case complexity of lines 6-11 of function bar? A. O(1) B. O(N) C. O(i) D. O(log N) E. O(sqrt N) F. O(A[i]) G. O(N sqrt N) H. O(N log N) I....

  • What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The...

    What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The input is an array A of size n. You may assume that n is a power of 2. (NOTE: It doesn’t matter what the algorithm does, just analyze its complexity). Assume that the non-recursive function call, bar(A1,A2,A3,n) has cost 3n. Show your work! Next to each statement show its cost when the algorithm is executed on an imput of size n abd give the...

  • What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The...

    What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The input is an array A of size n. You may assume that n is a power of 2. (NOTE: It doesn’t matter what the algorithm does, just analyze its complexity). Assume that the non-recursive function call, bar(A1,A2,A3,n) has cost 3n. Show your work! Next to each statement show its cost when the algorithm is executed on an imput of size n abd give the...

  • Find the worst case runtime f(n) for the following algorithms. Specify the number of operations executed...

    Find the worst case runtime f(n) for the following algorithms. Specify the number of operations executed for an input size n, for the worst case run time as a function of n. Circle statement(s) and draw a   line to the right side specifying the number of operations. If statement(s) are a part of an iteration of n, specify the total number of iterations as a function of n. Algorithm-01 int sum = 0; int j = 1; while ( <=...

  • 4. Big-Oh and Rune time Analysis: describe the worst case running time of the following pseudocode...

    4. Big-Oh and Rune time Analysis: describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. howing your work is not required (although showing work may allow some partial t in the case your answer is wrong-don't spend a lot of time showing your work.). You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for...

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
ADVERTISEMENT