In my last assignment I was given a question :-
An array contains four occurrences of 0, five occurrence of 1 and three occurrence 0f 2 in any order. The array is to be sorted using swap operations (elements that are swapped need not be adjacent). What is the minimum number of swaps needed to sort such an array in the worst case? Find the complexity of the program.
I think I did mistake in that I took the following array as worst case
and minimum number of swaps that I got was 7( I pre assumed array to be like which is wrong ) .
I want to know right answer for this along with time complexity (which sorting used)?
@querty1234 @ssrivastava990 @galencolin