If you want to get the original length for any depth, where the max size equals the originalLength + (originalLength / 2 ^ depth), you can set up the equation m = x + (x/2^d)
. Solving this for x
, you get x = m * 2^d/(2^d + 1)
for any d
, where d
equals the depth
, x
equals the initial size
, and m
equals the maximum size
(512 in your case). So, for your question of what's the initial size if the depth equals 2 and the max size = 512, the initial size is 409.6
.
For future reference, a better place to ask this probably would've been https://math.stackexchange.com/. (Since this question's a little more about math and equations that programming).
HTH