Given `N' objects coloured red, white or blue, sort them so that objects of the same colour are adjacent, with the colours in the order red, white and blue.
The technique to solve this problem is three way partitioning ie representing Red with 0 , White with 1 and Blue with 2 . The variables are lo , mid , hi .
lo = 1st position where value is not 0 .
hi = 1st position from end where value is not 2 .
mid = position past lo where value is not 1 .
sourcecode :
The technique to solve this problem is three way partitioning ie representing Red with 0 , White with 1 and Blue with 2 . The variables are lo , mid , hi .
lo = 1st position where value is not 0 .
hi = 1st position from end where value is not 2 .
mid = position past lo where value is not 1 .
sourcecode :



