Question

find complexity Problem 1 Find out the computational complexity (Big-Oh notation) of the code snippet: Code...

find complexity

Problem 1

Find out the computational complexity (Big-Oh notation) of the code snippet:

Code 1:

for (int i = n; i > 0; i /= 2) {

for (int j = 1; j < n; j *= 2) {

    for (int k = 0; k < n; k += 2) {

              // constant number of operations here

    }

}

}

Code 2: Hint: Lecture Note 5, Page 7-8

void f(int n) {

if (n > 0) {

    DoSomething(); // O(1)

    f(n - 1); f(n - 1);

}

}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
find complexity Problem 1 Find out the computational complexity (Big-Oh notation) of the code snippet: Code...
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
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