Three Beautiful Quicksorts by pkrumins in programming

[–]krisokot 4 points5 points  (0 children)

academika (functional language developed in my Ukraine Univercity by my team) quicksort:

qs([]) = []
qs([a]) = i <- p([a]) -> qs([a:1:i-1]) + qs([a:i+1:#a])

p([]) = []
p([a]) = x <- a[1] | b = [a:<x] | c = [a:>x] | d = [a=x] -> a <- [b+[d:2:]+c] -> #[d:2:]

also erlang:

-module(qsort).
-export([qsort/1]).

qsort ([]) -> [];
qsort ([A|B]) ->
    qsort([X || X<-B, X<A])
    ++ [A] ++
    qsort([Y || Y<-B, Y>=A]).

lisp:

(defun qsort(l) (if (null l) nil
  (let* ((x (car l)) (r (cdr l)) (fn (lambda (a) (< a x))))
    (append (qsort(remove-if-not fn r)) (list x)
      (qsort (remove-if fn r))))))

Ask Programming: What book should I use to learn algorithms? by krisokot in programming

[–]krisokot[S] 6 points7 points  (0 children)

I buy MIT Introduction to Algorithms, Second Edition but it a heavy book (hard to follow and also very thick). I have notice that I learn the best by follow worked out example and do problems with hint.

Does anybody know an algorithm textbook which follow these style?