What is the best case time complexity of above mentioned question improvised selection sort algorithm?
n-1 comparisons + 3(n-1) swaps
n-1(n/2) comparisons + 3(n-1) swaps
log n comparisons + 3(n-1) swaps
n log n comparisons + 3(n-1) swaps
best case means, already array is in sorted order, so if it is in sorted order then only one time max() function will be executed where we are checking largest value only once with n-1 comparisons. after first iteration of outer for loop we will get to know that its already sorted. so no of comparisons will be just n-1. for best case and worst case no of swapping will remain same as 3(n-1).
Back To Top