6. Consider the following alternative version of bubble sort to sort arr, which has length n:
1 Starting at the right end of the array, compare adjacent entries, swapping if the entry with the higher index is smaller.
: Specifically: start by comparing arr[n-2] and arr[n-1]. . If arr[n-2] > arr[n-1], swap those two entries . Then move left to the next adjacent pair, and continue all the way down to comparing entries at the 0 and 1th indices.
2 Now, starting at the left hand side of the array, compare adjacent arrays, swap- ping if the entry with the higher index is smaller.
: Specifically: start by comparing arr[o] and arr[1]. . If arr[o] > arr[1], swap those two entries : Then move right to the next adjacent pair, and continue all the way up to comparing entries at the n -- 2 and n -- 1th indices.
3 Repeat step 1, then 2, then 1, then 2, until you have gone either up or down the array a total of n times.
(a) Give an argument for why this algorithm successfully sorts an array.
(b) What is the computational complexity O of this algorithm? Explain