[Solved] Time complexity max min [closed]
The average case complexity for both cases is O(n). if k is the number of times the first if fails, then the number of comparisons is 2*n – 2 – k. maxmin(a,n,max,min){ max=min=a[1]; for i=2 to n do{ // goes through the loop n-1 times if a[i]>max then max:=a[i]; // out of n-1 times succeeds … Read more