Are there any worse sorting algorithms than Bogosort (a.k.a Monkey Sort)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 7 years ago. Improve this question My co-workers took me back in time to my University days with a discussion of … Read more

How to find the kth largest element in an unsorted array of length n in O(n)?

I believe there’s a way to find the kth largest element in an unsorted array of length n in O(n). Or perhaps it’s “expected” O(n) or something. How can we do this? 33 Answers 33 This is called finding the k-th order statistic. There’s a very simple randomized algorithm (called quickselect) taking O(n) average time, … Read more

Computational complexity of Fibonacci Sequence

I understand Big-O notation, but I don’t know how to calculate it for many functions. In particular, I’ve been trying to figure out the computational complexity of the naive version of the Fibonacci sequence: int Fibonacci(int n) { if (n <= 1) return n; else return Fibonacci(n – 1) + Fibonacci(n – 2); } What … Read more