What is starvation?

Imagine you’re in a queue to purchase food at a restaurant, for which pregnant women have priority. And there’s just a whole bunch of pregnant women arriving all the time. You’ll soon be starving. 😉 Now imagine you are a low-priority process and the pregnant women are higher priority ones. =)

Why is number of bits always(?) a power of two? [closed]

That’s mostly a matter of tradition. It is not even always true. For example, floating-point units in processors (even contemporary ones) have 80-bits registers. And there’s nothing that would force us to have 8-bit bytes instead of 13-bit bytes. Sometimes this has mathematical reasoning. For example, if you decide to have an N bits byte … Read more

What is the Zipper data structure and should I be using it?

Let’s start with the Zipper-analog for lists. If you’d like to modify the nth element of a list, it takes O(n) because you have to copy the n-1 first elements. Instead, you can keep the list as a structure ((first n-1 elements reversed) nth element (remaining elements)). For example, the list (1 2 3 4 … Read more

What are the main differences between the Knuth-Morris-Pratt and Boyer-Moore search algorithms?

Moore’s UTexas webpage walks through both algorithms in a step-by-step fashion (he also provides various technical sources): Knuth-Morris-Pratt Boyer-Moore According to the man himself, The classic Boyer-Moore algorithm suffers from the phenomenon that it tends not to work so efficiently on small alphabets like DNA. The skip distance tends to stop growing with the pattern … Read more

Why can Conway’s Game of Life be classified as a universal machine?

Paul Rendell implemented a Turing machine in Life. Gliders represent signals, and interactions between them are gates and logic that together can create larger components which implement the Turing machine. Basically, any automatic machinery that can implement AND, OR, and NOT can be combined together in complex enough ways to be Turing-complete. It’s not a … Read more