Pictureprocedure MatchExistsA   for i = 2 to n     for j = 1 to i-1       if a_j = a_i then return true   return falseprocedure MatchExistsB BubbleSort(list)   for i = 1 to n-1     if a_i == a_i+1 then return true   return falseI calculated the worst-case running time of each algorithm using  notation, and for the first algorithm, I got (n). When i=2, there is 1 iteration in the inner loop. When i=3, there are 2, and so on. At i=n, there are n-1 iterations. Thus, the total is 1+2+...+n-1 => n(n-1)/2 => (n)For the second one, the question assumes BubbleSort has (n) at worst-case. The loop then has n-1 iterations i.e. (n). Thus, max ( (n) , (n) ) = (n).It is right that both of them have the same running time? I feel like I'm doing something wrong or I am not understanding the question correctly.
Which of these algorithms are more efficient in big- notation?
algorithms;algorithm analysis