Category

Archive for the 'classic' Category

Finding an enclosing interval

( interview and classic )

A question often asked in interviews is: what’s the best way to store a set? There are many different ways to store well-ordered data so that it can be queried quickly. Many people find that a hash table gives them the best performance characteristics, so much so that if you are in an […]

Random Permutation

( interview and classic )

So, I’ve totally been writing this blog for almost a week, but so far I haven’t talked about how an actual algorithm works. Here’s a classic algorithm.
Let’s say you have an array of n elements a[0] through a[n-1]. You would like to generate a random permutation of this array. This means that […]