Page 1292 - AP Computer Science A, 7th edition
P. 1292

5. (A) The values of k are, consecutively, 4, 3, 2, and 1. The values of randPos are, consecutively, 3, 2, 0, and 0. Thus, the sequence of swaps and corresponding states of nums will be:
swap nums[4] and nums[3]
swap nums[3] and nums[2]
swap nums[2] and nums[0]
swap nums[1] and nums[0]
87645 87465 47865 74865
Thus, the element in nums[2] is 8.




























































































   1290   1291   1292   1293   1294