Jim's
Tutorials

Spring 2012
course
navigation

Sorting

I started reading chapter 5 which is about sorting. There was a lot of interesting stuff in there. When I got to quicksort and remembered that it was one the more commonly used algorithms I decided to implement it. Since it's called quicksort I decided I might as well make it a bit faster by doing it in C. Here it is running:
$ make quicksort cc quicksort.c -o quicksort $ ./quicksort TEST 1: before sorting: [67, 6, 42, 55, 41, 54, 99, 50, 91, 58] after sorting: [6, 41, 42, 50, 54, 55, 58, 67, 91, 99] TEST 2: before sorting: [481, 689, 490, 98, 459, 679, 986, 990, 701, 868, 630, 383, 415, 299, 349, 346] after sorting: [98, 299, 346, 349, 383, 415, 459, 481, 490, 630, 679, 689, 701, 868, 986, 990] TEST 3: before sorting: [3, 0, 3, 7, 2, 6, 2, 8, 4, 6] after sorting: [0, 2, 2, 3, 3, 4, 6, 6, 7, 8]
There were a few other interesting things in the chapter that I love to talk about when we meet. I'm remembering an in-place version of merge sort that we talked about in the algorithms class that might be neat to try.
http://cs.marlboro.edu/ courses/ spring2012/jims_tutorials/ sam/ Sorting
last modified Tuesday April 17 2012 11:23 pm EDT

attachments [paper clip]

     name last modified size
[COD]quicksort.c Apr 17 2012 11:24 pm 3.53kB