Monday, August 29, 2011

Scala quicksort

Here's a version of quicksort in Scala that I took from the excellent "Scala by Example" pdf from the scala website. The main algorithm is intact; I just thought it would be nice to get a print out of the steps being performed. So basically the program has been changed to include a few extra variables so that their value can be printed to the console. The unsorted input array has been hard-coded into the program just to avoid writing additional code to parse input arguments.

If you have scala installed, you can copy and paste the code to a file, compile it (scalac filename), run (scala compiledfilename) and see the output. Enjoy!


No comments: