Thanks for the help :) Big O (Definition) We say that g(n) is O(f(n)) - read as,
ID: 3812546 • Letter: T
Question
Thanks for the help :)
Big O (Definition) We say that g(n) is O(f(n)) - read as, "g of n is Big O of f of n" - when there exists some constants k and n_0 (pronounced as "n nought or as n-sub-zero") such that: g(n) is bound by k * f(n) for problem size n >= n_0. Given the growth function, g(n) = 2n^2 + 4n + 3, determine the Big O. Prove that your analysis is correct by finding a constant k, and a constant no that satisfy the definition of Big O. Given the growth function, g(n) = 4n^3 + n + 1, determine the Big O. Prove that your analysis is correct by finding a constant k, and a constant n_0 that satisfy the definition of Big O. Given the following code segment, determine the Big O. Assume n is the number of elements in the array, myArray. void myMethod(int myArray[], int n) {int num1 = 15; int num2 = 20; int result = num1 + num2; for (int i = 0; iExplanation / Answer
1) Given that g(n) = 2n^2 + 4n + 3
For this case g(n) = O(n^2)
Let us take k = 3 and n0 = 10
for n = 10
n^2 = 100 and 4n+3 = 43
So n^2 > 4n+3
For n > 10 the difference between n^2 and 4n+3 will only increase. Because n^2 increase at faster pace than 4n+3.
So for n>=10
n^2 > 4n+3 Adding 2n^2 on both sides
3n^2 > 2n^2 + 4n + 3
So 3n^2 > g(n) for n>=10
Hence proved.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.