Question: Consider the following snippet of pseudocode that takes as input an array of n integers. 1: function algorithm(A) 2: n + length of A
Consider the following snippet of pseudocode that takes as input an array of n integers. 1: function algorithm(A) 2: n + length of A 3: num_matches +0 4: for i in [0: n] do i ranges from 0 to n - 1 5: for j in [i + 1:n] do j ranges from i + 1 ton-1 6: if A[i] = =A[j] then 7: num_matches + num_matches + 1 8: return num_matches Your task is to: 1) upperbound the running time of the algorithm in terms of n using Onotation. 2) lowerbound the running time of the algorithm in terms of n Using notation.
Step by Step Solution
3.26 Rating (144 Votes )
There are 3 Steps involved in it
Answer 1 Upperbound the running time of the algorithm in terms of n using Big O notation In the give... View full answer
Get step-by-step solutions from verified subject matter experts
