This is the story of a clever trick that's been around for
at least 35 years, in which array values can be left
uninitialized and then read during normal operations,
yet the code behaves correctly no matter what garbage
is sitting in the array.
Like the best programming tricks, this one is the right tool for the
job in certain situations.
The sleaziness of uninitialized data
access is offset by performance improvements:
some important operations change from linear
to constant time.
Alfred Aho, John Hopcroft, and Jeffrey Ullman's 1974 book
The Design and Analysis of Computer Algorithms
hints at the trick in an exercise (Chapter 2, exercise 2.12):
Develop a technique to initialize an entry of a matrix to zero
the first time it is accessed, thereby eliminating the O(||V||2) time
to initialize an adjacency matrix.
Keep reading
Out of respect for the author only the opening is shown here. Read the rest on the original site, or in HorizonReader with highlights, notes and AI help.
My post “Floating-Point Printing and Parsing Can Be Simple And Fast” depends on fast unrounded scaling, defined as: The unrounded form of , , is the integer value of concatenated with two more bits: first, the “½ bit” from the binary repres
Introduction A floating point number has the form where is called the mantissa and is a signed integer exponent. We like to read numbers scaled by powers of ten, not two, so computers need algorithms to convert binary floating-point to and
Introduction Donald Knuth wrote his 1989 paper “A Simple Program Whose Proof Isn’t” as part of a tribute to Edsger Dijkstra on the occasion of Dijkstra’s 60th birthday. Today’s post is a reply to Knuth’s paper on the occasion of Knuth’s 88t
These are the posts in the “Floating Point Formatting” series, which started in 2011 and continued in 2026. “Floating Point to Decimal Conversion is Easy” (2011) “Pulling a New Proof from Knuth’s Fixed-Point Printer” (2026) “Floating-Point
I have been debugging some code I did not write and was reminded of this technique. I’m sure it’s a very old debugging technique (like bisection), but it should be more widely known. Suppose you have one test case that’s failing. You can ge