Live data from Hacker News

"The worst algorithm in the world?"

bosker.wordpress.com

1–10 of 73 posts

Re: "The worst algorithm in the world?"

#4
post #3

Interesting writeup, thanks. OT: For all its fame, has any of you ever needed to calculate Fibbonacci numbers in real life? I haven't.

It seems like I had to as part of an interview once. Still, I have needed to write recursive functions many, many times and it's good to review some of what can go wrong.

Re: "The worst algorithm in the world?"

#6

I always liked the sort where you randomize the elements, check to see if they're sorted, and if not try again.

Yeah, I recalled the name as random sort, and was pleasantly surprised when the bogosort link directed to the same algorithm. I particularly enjoyed the "Quantum Bogosort" algorithm on the Wiki page.

http://en.wikipedia.org/wiki/Bogosort#Quantum_bogosort

Re: "The worst algorithm in the world?"

#7
Dunno. IIRC Every time I have seen the "bad" Fibonacci recursive algorithm has been followed by the "good" recursive one (bottom-up), which is O(1) in size if your language/implementation does tail-call elimination...

Re: "The worst algorithm in the world?"

#9
> It’s not just bad in the way that Bubble sort is a bad sorting algorithm; it’s bad in the way that Bogosort is a bad sorting algorithm.

Nonono, Bogosort is way worse than naive recursive fibonacci - the former doesn't even guarantee termination, recursive fibonacci still does.

If you want to calculate fibonacci numbers not as a misguided exercise in algorithms but actually efficiently, use an algebraic form: http://en.wikipedia.org/wiki/Fibonacci_number#Computation_by...

Post reply on HN