This is a homework question. I have been asked to identify what sort this code below implements.
sort(arr of length n, left, right): if (left > right): return for i from 0 to n: if i >= right and arr[left] > arr[i]: left = i swap(arr, left, right) left = right right = right + 2 if (right < n): sort(arr, left + 1, right - 1) sort(arr, right - 1, left) sort(arr): sort(arr, 0, 0)
After writing the code's trace on paper, I've come to think that it's a selection sort because from the original table [50, 15, 33, 27, 89, 12, 18] after passing one time through it we obtain [12, 15, 33, 27, 89, 50, 18]. We looked for the smallest element in the table and then put it first. this seems like the typical behavior of selection sort.
I want to confirm if I am right or wrong because I do not have access to the solution of the problem.