We’ll now turn to counting swaps. In these exercises, you should count as a “swap” the exchange of an element A[i] with itself. (So if i = minIndex in Line 6 of selectionSort, Line 6 still counts as performing as swap.) For the worst-case input array of size n, how many swaps are done by these algorithms?
1.selectionSort
2. insertionSort
3. bubbleSort
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here