Question: 3. Identify the basic operation and construct a function C(n) that characterizes the time complexity of the algorithm in i) the best case (i.e., Chest(n))

3. Identify the basic operation and construct a function C(n) that characterizes the time complexity of the algorithm in i) the best case (i.e., Chest(n)) and ii) in the worst case (i.e., Cworst(n)). Determine the order of growth of Cbest(n) and Cworst(n) using 0 notation. Foo3 (m, A[O..n-1]) // Description: count the number of elements in the array that are greater // than m // Input: a positive integer m and an array sorted in ascending order // Output: the number of elements in the array that are greater than m. for if 0 to n-1 do if A[i] > m return n-i return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
