Microsoft's programming problem
You should
read the background story before continuing. Or you could choose
to just continue, but I think the blog entry may give you a bit of the
background as to why I've coded such useless applet.
Color sorting array of N balls, and each ball could have a color from
a set of M colors.
Notes:
- I've used java.util.Random() to assign a color (from 10) to each
ball.
- Click the "Reset" button to randomize
- Click the "Sort" button to sort
- There are a couple of Thread.sleep() calls, so you can see how the
sorting is taking place
- There are 25 columns and 24 rows (600 balls)
- The indices given on the right are the indices within the 2D array
where the next group of same colored balls begins
Source Code
|