What is the worst case computational complexity of the following code snippet in terms
of Big O notation?
int sum = 0
for (int i=0; i<n; i++)
for (int j=0; j<i; j++)
sum = sum+j; - answerO(n^2) (n squared)
What is the computational complexity of the following code snippet?
int result = 0
for (int i = 0; i < n; i++)
for (int j = i; j > 0; j--)
result += 1; - answerO(n^2)
What is the worst case computational complexity of the following code snippet in terms
of Big O notation?
int x = 1
while (x < n)
x *= 2 - answerO(log n)
What is the worst case computational complexity of the following code snippet in terms
of Big O notation?
result = 0
for (int i = 0; i < n; i++)
result += i;
for (int j = 1; j < m; j *= 2)
result *= j; - answerO(n + log m)
Which of the following functions T(n), belongs to the family of O(n^3*(log2n)) -
answern^3*(log2(log2n))
n^2+n+5000
1000000
n^3
n^3*(log3n)
, What is the worst case computational complexity of the following code snippet in terms
of Big O notation?
result = 0
for (i=0; i<10; i++)
for (j=0; j<i; j++)
result += i*j; - answerO(1)
An algorithm's runtime is given by T(n, m) = 3m^3+4m^3*log2m+3n^2+n+100. -
answerO(m^3*log2(m)+n^2)
Which family/families does the following function T(n) = n^5*log2(n) belong to? Check
all that apply. - answerΩ(10000)
O(2000n^5+2000^n)
O(n^5log3(n))
Which of the following are FALSE? Select all that apply. - answer-The best case time
complexity of linear search is O(1) and occurs when there is just one element in an
array
-If the growth rate for algorithm A can be represented by T(n) = n and the growth rate for
algorithm B can be represented by U(n) = log(n) we can say that algorithm A is faster
than algorithm B.
Examine the following code snippets below and determine which has a slower growth
rate. Consider "c" to be a positive integer constant (c > 1) :
Snippet B:
for(int i = 0; i < n; i++){
for(int j = n; j >= 100; j--){
print("Hello");}} - answerSnippet A has a slower growth rate than Snippet B
Answer: Snippet A will grow at f(n) = n*logcnSnippet B will grow at g(n) = n*n = n2. So,
A will have a slower growth rate
What is the computational complexity of adding an item to a Queue in the worst case in
terms of Big O notation? - answerO(1)
Consider the following operations on a stack
push(10);
push(5);
pop();
push(7);
pop();
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Dreamer252. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $12.49. You're not tied to anything after your purchase.