Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Q1. What is the Big-O notation of the following algorithm (assume that all variables have been declared):
   for (int i=1; i<= n; i++)
       sum = sum + i * (i + 1);

Q2. What is the Big-O notation of the following algorithm (assume that all variables have been declared):
   for (int i = 5; i <= 2 * n; i++)
       System.out.println(2 * n + i - 1);

Q3. What is the Big-O notation of the following algorithm:
   for (int i = 1; i <= 2 * n; i++)
       for (int j = 1; j <= n; j++)
           System.out.println(2 * i + j);
               System.out.println(" ");


Q4. What is the Big-O notation of the following algorithm:
   for (int i = 1; i <= n; i++)
       for (int j = 1; j <= n; j++)
           for (int k = 1; k <= n; k++)
               System.out.println(i + j + k);


Q5. Each of the following expressions represents the number of inputs for
certain algorithms. Write them in Big O notation (e.g, n + 2 -> O(n)):

- n2 + 6n + 4
- 5n3 + 2n + 8
- (n2 + 1)(3n + 5)
- 5(6n + 4)
- n + 2log2n - 6
- 4nlog2n + 3n + 8


What I have tried:

What is the Big-O notation of the following algorithm
Posted
Updated 27-Jul-20 6:22am
Comments
Patrice T 27-Jul-20 12:16pm    
What are your answers ?

 
Share this answer
 
Comments
CPallini 27-Jul-20 16:30pm    
5.
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900