Lampsort: Leslie Lamport's Non-recursive Quicksort
bertrandmeyer.com
Lampsort: Leslie Lamport's Non-recursive Quicksort
1–10 of 46 posts
Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#2It reminds me of the way you turn recursive depth-first search (recurse on children that have not been visited) into non-recursive depth-first search (push the children that have not been visited onto the DFS stack). Calling it "non-recursive" is a bit misleading, since you're trading recursion stack space for an actual data stack to maintain the recursion you are supposed to avoid -- but it is a useful program transformation to know.
Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#3I'm not completely sure what distinction Meyer is trying to draw between the implementation he discusses, and "making the stack explicit". He ends up with a "set" of intervals that he pushes onto and pops from, which might as well have been a stack of arguments.
Is the point that the order you pull things out of the set doesn't matter, so demanding that it behave as a stack is overly prescriptive?
Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#4Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#5Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#6Where Quicksort uses the recursion stack to maintain the `intervals` implicitly, Lampsort instead uses some set data structure to maintain this set of subproblems explicitly. It reminds me of the way you turn recursive depth-first search (recurse on children that have not been visited) into non-recursive depth-first search (push the children that have not been visited onto the DFS stack). Calling it "non-recursive" i…
Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#7https://gist.github.com/joelgrus/9dc47ebb22243fe990e5
I think it's right. :)
Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#8So it is reasonable to argue this is a more abstract, "fundamental" implementation of the sort. Intuitively, I'm not sure it's that different from "remov[ing] the recursion, for example by making the stack explicit", then removing the stack, but it's sure interesting.
Edit: See https://news.ycombinator.com/item?id=8713160 for more context; this is correct, but the point is not really about how the code works.
Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#9Re: Lampsort: Leslie Lamport's Non-recursive Quicksort
#10First question was why anybody would present this using Eiffel. That's apparently answered at the bottom, but I still don't understand. Eiffel is good at being abstract or something? But isn't the code presented a concrete implementation of a single way to do things?