Question
Hi, I'm in need of help with this assignment, it's C++ but deals with Big O. This is to be done with pencil and paper,
Hi, I'm in need of help with this assignment, it's C++ but deals with Big O. This is to be done with pencil and paper, no code at all. Here are the problems:
- Does Big O indicate how many times your program will loop or how many instructions will be executed in a loop? Explain please. I am confused.
- Given the following formulas for algorithm efficiency, express each formula in Big O notation:
- n3 + 5 n2
- 3n2 + 5n* 5n
- 250n2 * 100n
- the number of times a number n can be divided by 5 before dropping below 5.
What is the Big O for each of the following code?
- for ( i = 0; i < n; i ++ )
{ j += i; }
- for ( k = 2*n; k > 0; k-- )
{ j = k * 2;
for ( j = 0; j < n*n; j++ )
tot = tot + j * k;
}
- i = n;
while ( i > 0 )
{ acc = acc + i * n * n;
i = i / 2;
}
- k = n * n;
for ( i = 0; i < n; i++)
while ( k > 0 )
{ acc = acc + i * k;
k = k / 2;
}
- for ( i = 0; i < n*n; i ++ )
{ k = 0;
while ( k < n*n )
{ acc = acc + k * i;
k = k * 2;
}
}
- k = n * n;
for ( i = 0; i < n; i++)
{ t = t + i * i;
s = t / 2;
}
while ( k > 0 )
{ acc = acc + i * 5;
k = k / 2;
}
- int *p;
p = head; ; beginning of link list
while ( p != null && ( p->value != target ) p = p -> linky;
- Why is the Big O of the Bubble sort and the Selection Sort consider to be n2?
- What is the Big O value of 'Insert' operation into a Stack?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started