Question

1). What is the complexity of the following code snippet? { for (int count2 = 0;...

1). What is the complexity of the following code snippet?

{

for (int count2 = 0; count2<n; count2++)

{

/*some sequence of O(1) step*/

}

}

select one:

a. O(N^2)

b. O(Log N)

c. O(1)

d. O(N!)

2). What is the complexity of the following code snippet?

for (int count = 0; count<n; count++)

{

printsum(count)

}

select one:

a. We need to know the complexity of the printsum() function.

b. O(Log N)

c. O(1)

d. O(N)

e. O(N^2)

3). what is the complexity of the following function?

for (int i=0; i<m, i++)

    for(int j = 0: j<n; j++)

      if (a[i][j] %2 == 0)

W++

Select one:

a. O(mn)

b. O(n)

c. O(1)

d. O(m)

4). What is the complexity of the following function?

for (int count = 0; count <n-3; count++){

for (int count2 =0; count2<n; count2 =count2*2){

    //some sequence of O(1) steps

}

}

Select one:

a. O(N)

b. O(Log N)

c. O(N^2)

d. O(N log N)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1.
a. O(N^2)

2.
a. We need to know the complexity of the printsum() function.

3.
a. O(mn)

4.
d. O(N log N)

Please up vote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
1). What is the complexity of the following code snippet? { for (int count2 = 0;...
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