O(g(n)) = { f(n): there exist positive constants c and n0 such that 0 <= f(n) <= c*g(n) for all n >= n0}
1.
a) Clearly, for c = 1730 and n >= 1, we have
0 <= 1729 <= c
Hence, 1729 = O(1)
b) For c = 2 and n >= 0, we have
0 <= 2n2 - 4n - 3 <= c*n2
Hence, 2n2 - 4n - 3 = O(n2)
2. f(n) = 2n2(n - 1) = 2n3 - 2n2
There does not exist any positive integer c such that
0 <= f(n) <= c*n2 where n >= 0
Hecne, f(n) != O(n2)
3.
a) Given that f(n) = O(g(n))
=> 0 <= f(n) <= c*g(n) where c is a positive constant
=> 0 <= k*f(n) <= k*c*g(n)
=> 0 <= k*f(n) <= c1*g(n) where c1 = k*c
Clearly, k*f(n) = O(g(n))
b)
Given that f(n) = O(g(n))
=> 0 <= f(n) <= c1*g(n) where c1 is a positive constant ------> (1)
Given that g(n) = O(h(n))
=> 0 <= g(n) <= c2*h(n) where c2 is a positive constant ------> (2)
Combining 1 and 2, we get
0 <= f(n) <= c1*g(n) <= c1*c2*h(n)
or, 0 <= f(n) <= c1*c2*h(n)
=> 0 <= f(n) <= c3*h(n) where c3 = c1*C2
Hence, f(n) = O(h(n))
NOTE: As per HOMEWORKLIB POLICY, I am allowed to answer only 4 questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.
1. [5 marks Show the following hold using the definition of Big Oh: a) 2 mark...
#1. Using the definition of big-O, prove that f(x) = 5x^4+x^3+8x-2 . Show all work. #2. void bubbleSort(Student myClass[], int size) { int pass = 0; // counts each pass of the sort bool done = false; // whether sorted or not // each pass puts one element into its sorted position, // smallest value bubbles to the top of the array while (!done) { done = true; // possibly sorted // compare consecutive elements, swap if out of order...
Searching/sorting tasks and efficiency analysis - Big-oh For each problem given below, do the following: 1. Create an algorithm in pseudocode to solve the problem. 2. Identify the factors that would influence the running time of your algorithm. For example, if your algorithm is to search an array the factor that influences the running time is the array size. Assign names (such as n) to each factor. 3. Count the operations performed by the algorithm. Express the count as a...
Question 3: Given the following two code fragments [2 Marks] (i)Find T(n), the time complexity (as operations count) in the worst case? (ii)Express the growth rate of the function in asymptotic notation in the closest bound possible. (iii)Prove that T(n) is Big O (g(n)) by the definition of Big O (iv)Prove that T(n) is (g(n)) by using limits
Formal Definitions of Big-Oh, Big-Theta and Big-Omega: 1. Use the formal definition of Big-Oh to prove that if f(n) is a decreasing function, then f(n) = 0(1). A decreasing function is one in which f(x1) f(r2) if and only if xi 5 r2. You may assume that f(n) is positive evervwhere Hint: drawing a picture might make the proof for this problem more obvious 2. Use the formal definition of Big-Oh to prove that if f(n) = 0(g(n)) and g(n)...
When using an array to implement a list ADT, what is the time complexity (Big-Oh) for finding an element in the list with N elements? (C++)
S19-A6.pdf 2/5 Rutgers University CS111 - Inlroduction to Computer Science Spring 2019 Problem 5 Big-oh For cach problen given below, do lhe following 1. Creste a algrithm in psudood to solve the proble 2. Identify the factors that would influence the running time of your algorithm. For exarple, if your alorithm ia to search an array th fator that influeuxs the runnin time is the array size. Assign names (such as n) to each factor. 3. Count the operations performed...
Analysis of Algorithms Fall 2013 Do any (4) out of the following (5) problems 1. Assume n-3t is a power of 3 fork20. Solve accurately the following recursion. If you cannot find the exact solution, use the big-O notation. Tu) T(n)Tin/3)+2 2. Suppose that you have 2 differeut algorithms to solve a giveu probleen Algorithm A has worst-case time complexity e(n2) and Algorithm B has worst-case time complexity e(nlog n). Which of the following statements are true and which are...
[12 marks] Using the definition of big-O, show that f(x) is big-O of g, where: f(x) = 2* + 33 and g(x) = 3* Show the details of your work to obtain a full mark.
QUESTION 3 To show that f(x) is O(g(x) using the definition of big o, we find Cand k such that f(x) < Cg(x) for all x > k. QUESTION 4 Finding the smallest number in a list of n elements would use an OU) algorithm.
Prove each of the following using the definition of Big-Oh. a)(?+1)5is O(?5) b)2?+1is O(2?) c)If ?(?)is a polynomial in ?, then ????(?)is ?(log?)