Saturday, October 01, 2005

Sorting

Sort an array of size n containing integers between 1 and K, given a temporary scratch integer array of size K.

1 Comments:

At 6:34 PM, Blogger Foobar said...

Go through the array, everytime u see a number between 1 and k, increment the count in the scratch array indexed by k.

After it is done, go through the scratch array and seeing the count for 1, put so many 1's in the given array, replacing its original contents.

 

Post a Comment

<< Home