The big takeaway from the logic of the loop is that, X is the index of the element that has the maximum value and Z is the index of the element that has the minimum value.
After the loop, nothing touches the values of X and Z. The SwapElements subprogram only swaps the values in the list, at...