http://www.cs.washington.edu/education/courses/322/96w/hw1/hw1.html
More generally, strings of length n+1 are listed immediately after the
strings of length n. Those strings of the same length are listed in
alphabetical order. Notice that the rank of the string in the
enumeration ordering of
is
, that is, the rank of
is
, the rank of
is
, the rank
of
is
, and so on.