This question is admittedly very programming related, but I felt that it is better suited to the Mathematics crowd than Stack Overflow.
I would like to generate Hlibert walks through the pixels in an image (or really, any 2d coordinate space), but I would like to consume as little memory as possible. However, given how the Hilbert curve is defined, I would be required to generate the moves (N, S, E, or W) all at once, consuming much more memory that I would like.
Is it even possible to generate a Hilbert curve in an "online" fashion, with sub-linear memory space with respect to the order of the curve?
For reference, this is the definition of the Hilbert curve that I'm using, giving relative directions:
$$\begin{align} hilbert(order) &= A_{order+1} \\ A_0 &= [\,] \\ B_0 &= [\,] \\ C_0 &= [\,] \\ D_0 &= [\,] \\ A_n &= [B_{n-1}, N, A_{n-1}, E, A_{n-1}, S, C_{n-1}] \\ B_n &= [A_{n-1}, E, B_{n-1}, N, B_{n-1}, W, D_{n-1}] \\ C_n &= [D_{n-1}, W, C_{n-1}, S, C_{n-1}, E, A_{n-1}] \\ D_n &= [C_{n-1}, S, D_{n-1}, W, D_{n-1}, N, B_{n-1}] \end{align}$$
An ideal implementation would be implementable as a "iterator" (C#, etc) or "sequence" (Haskel, etc)
I believe that I have found a solution, but I need help verifying its memory complexity. I believe it to be O(n) with respect to the order of the curve, since the stack never grows beyond
orderelements, and each element is a constant size.