The pseudocode you provided represents the selection sort algorithm.
Here's a brief explanation of why this is the case:
- The outer loop (
while i < size - 1
) iterates through each element in the array except the last one. - The inner loop (
while j between(i + 1 and size)
) finds the smallest element in the unsorted portion of the array. - It maintains an
index
variable to track the position of the smallest element found. - After the inner loop completes, the smallest element is swapped with the current position (i), which is characteristic of how selection sort operates.
Therefore, the correct response is selection sort.