text: solve this puzzle? an array contains 4 occurences of 0s, 7 occurences of 1s and 9 occurences of 2s in any order. the array is to be sorted using only swap operations. what is the minimum number of swaps needed in the worst case to sort the array? it the worst case, none of the 0's is in the correct place, so it will take 4 swaps to put them in the correct the first 4 slots of the array. that leaves you with 7 1s and 9 2s. it will take you 7 swaps to get the 1s into the correct positions. the worst case will look like: 11112222222221110000  in general if you have n objects in broken into subsets, it will take you minimum of n - (size of largest subset) exchanges to get them into position by swapping. swap all the smaller subsets into position first, and the largest subset will end up in the correct position.