Question: Q1. [10 marks] Consider the algorithm BUBBLESORT shown below, where arr[i 1] arr[i] swaps the values of the given array elements and takes constant number

 Q1. [10 marks] Consider the algorithm BUBBLESORT shown below, where arr[i

Q1. [10 marks] Consider the algorithm BUBBLESORT shown below, where arr[i 1] arr[i] swaps the values of the given array elements and takes constant number of basic operations. What is the worst case time complexity (using Big-Oh) of this algorithm? Justify your answer. Algorithm BUBBLESORT(arr, n) 1: if n arr[i] 5: arr[i-1] arr[i] 6: bubbleSort(arr, n - 1) = . Q2. [26 marks] Answer the following questions related to O(.), 2(.) and (.). (i). [8 marks] Let f(n) = 3 log2 n and g(n) Vn. Using the basic definition of O- notation, prove f(n) = O(g(n)) and g(n) # (f(n)). - (ii). [5 marks] What is the asymptotic (Big-Oh) complexity of the function g(n) = (na + nyn) (n + log n)? - (iii). [5 marks] What is the asymptotic (Big-Theta) complexity of the function g(n) = (n + 2n? + 3) (n + n^)? (iv). [8 marks] Let f(n) be an asymptotically nonnegative function. Using the basic definitions, prove that f(n) + Of(n)) = (f(n))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!