array swapping

Dutch Flag Problem

Problem Definition - Dutch Flag Problem The dutch flag looks like the below image. The problem "Dutch Flag Problem" derives its name from the arrangement of colors in the flag. The actual problem definition goes like this: Given an array of balls of three colors ( Red, White and Blue). The balls are kept in random positions in the array. We need to develop a mechanism which can arrange the balls in groups (based on colors). Below is the image of a possible input and the expected output. The balls of different colors in the above image are randomly distributed in the input where...
Read More