Are duplicate keys allowed in the definition of binary search trees?

I’m trying to find the definition of a binary search tree and I keep finding different definitions everywhere. Some say that for any given subtree the left child key is less than or equal to the root. Some say that for any given subtree the right child key is greater than or equal to the … Read more

What would a “frozen dict” be?

A frozen set is a frozenset. A frozen list could be a tuple. What would a frozen dict be? An immutable, hashable dict. I guess it could be something like collections.namedtuple, but that is more like a frozen-keys dict (a half-frozen dict). Isn’t it? A “frozendict” should be a frozen dictionary, it should have keys, … Read more

How does the HyperLogLog algorithm work?

I’ve been learning about different algorithms in my spare time recently, and one that I came across which appears to be very interesting is called the HyperLogLog algorithm – which estimates how many unique items are in a list. This was particularly interesting to me because it brought me back to my MySQL days when … Read more

How are multi-dimensional arrays formatted in memory?

In C, I know I can dynamically allocate a two-dimensional array on the heap using the following code: int** someNumbers = malloc(arrayRows*sizeof(int*)); for (i = 0; i < arrayRows; i++) { someNumbers[i] = malloc(arrayColumns*sizeof(int)); } Clearly, this actually creates a one-dimensional array of pointers to a bunch of separate one-dimensional arrays of integers, and “The … Read more