Question: Example : prove that f(n) = 5n 2 + 3n + 2 has Big Oh O(n 2 ) ! From the definition of Big Oh,
Example: prove that f(n) = 5n2 + 3n + 2 has Big Oh O(n2) ! From the definition of Big Oh, we can say that f(n) = 5n2 + 3n + 2 = O(n2), since for all n 1 : 5n2 + 3n + 2 5n2+ 3n2 + 2n2 5n2 + 3n + 2 10n2 . By assigning the constants C = 10, N = 1, its right f(n) C g(n). Thus, f(n) = 5n2 + 3n + 2 O(g(n)) = O(n
Please anser the below question using the method demonstrated above.
Please show all compariosons, how you get C, how you get n0, and how you calculate ccomplexity using the above method.
What is the order of complexity? Find c and n such that cn > n for all n0. Please explain how you arrived at your answer in detail.
def insert(element, sorted):
if len(sorted) == 0:
return [element]
else:
if sorted[0] >= element:
new_copy = sorted[:]
new_copy.insert(0, element)
return new_copy
else:
return [sorted[0]] + insert(element, sorted[1:])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
