Big-oh vs big-theta

Big-O is an upper bound. Big-Theta is a tight bound, i.e. upper and lower bound. When people only worry about what’s the worst that can happen, big-O is sufficient; i.e. it says that “it can’t get much worse than this”. The tighter the bound the better, of course, but a tight bound isn’t always easy … Read more

Quicksort vs heapsort

This paper has some analysis. Also, from Wikipedia: The most direct competitor of quicksort is heapsort. Heapsort is typically somewhat slower than quicksort, but the worst-case running time is always Θ(nlogn). Quicksort is usually faster, though there remains the chance of worst case performance except in the introsort variant, which switches to heapsort when a bad … Read more

What’s a good algorithm to generate a maze?

From http://www.astrolog.org/labyrnth/algrithm.htm Recursive backtracker: This is somewhat related to the recursive backtracker solving method described below, and requires stack up to the size of the Maze. When carving, be as greedy as possible, and always carve into an unmade section if one is next to the current cell. Each time you move to a new cell, … Read more

What is the meaning of “exclusive” and “inclusive” when describing number ranges?

The following function prints the powers of 2 from 1 through n (inclusive). This means that the function will compute 2^i where i = 1, 2, …, n, in other words, i can have values from 1 up to and including the value n. i.e n is Included in Inclusive If, on the other hand, your book had said: The following function prints the powers of … Read more