Thread
:
Programming Challenges?
View Single Post
14-08-2009, 10:40
#
15
danielf
cf.mega poser
Join Date: Jun 2003
Posts: 16,687
Re: Programming Challenges?
Quote:
Originally Posted by
LemonyBrainAid
Seeing as you're only using 10 random numbers, I suggest you actually create your own code for a bubble sort algorithm -
http://en.wikipedia.org/wiki/Bubble_sort
For large Ns, try quicksort.
Spoiler:
(defun quick-sort (a-list)
(let ((pivot nil)
(lesser nil)
(greater nil))
(when a-list
(cond ((= (length a-list) 1)
(list (first a-list)))
(t
(setf pivot (first a-list))
(dolist (item (rest a-list))
(if (<= item pivot)
(push item lesser)
(push item greater)))
(append (quick-sort lesser) (list pivot) (quick-sort greater))
)))))
http://en.wikipedia.org/wiki/Quicksort
__________________
Remember kids: We are blessed with a listening, caring government.
danielf
View Public Profile
Find More Posts by danielf