This blog is heavily inspired by Monogon's blog on the best branching factor for segment trees which I really recommend reading as it doesn't feature hard math and is really interesting :)
So as you might have guessed I wanted to get the optimal lifting power for binary lifting :)
so at first I thought that having a higher power would get us fewer levels which is actually true, but does it mean that high power is more optimal? I didn't know so I went through analyzing it mathematically
So in binary lifting we just loop at each "digit" in base-2 and do the jumps accordingly, so having $$$d_i$$$ in the $$$i$$$-th level would mean that we have to do $$$d_i$$$ jumps each with distance $$$2^i$$$ now if we are doing k-lifting we would loop at the "digits" in base-k and do the same thing
we currently have 2 factors affecting the jumps:- 1. the number of levels we have 2. the number of jumps per level
1. the number of levels we have
this is really easy to calculate, number N has about $$$\log_k(N)$$$ digits in base-k
2. the number of jumps per level
this is also really easy, each digit must be less than k that is $$$d_i \in \left[ 0, k \right)$$$ in base-k
The analysis
ok so as we have calculated, if we have a tree with $$$N$$$ nodes, in the worst case we would have to do approximately $$$(k-1)\cdot \log_k(N)$$$ jumps in total, to simplify the math we can replace $$$\log_k(N)$$$ with $$$\frac{\log(N)}{\log(k)}$$$ (where $$$\log(x)$$$ is the natural logarithm of $$$x$$$), so now we are doing $$$(k-1) \cdot \frac{\log(N)}{\log(k)}$$$, now since $$$N$$$ is independent from the base $$$k$$$ we can neglect it yielding $$$f(k) = \frac{k-1}{\log(k)}$$$ and we need to find the $$$k$$$ that minimizes this function so we will take its derivative, $$$f'(k) = \frac{\log(k) - \frac{k-1}{k}}{\log^2(k)} = \frac{\log(k) + \frac{1}{k} - 1}{\log^2(k)}$$$
from here we can try to find the value of k where it will make the function equal to 0 and we would be done however other than it being really annoying,
we would get $$$k = 1$$$ which is not even in the domain of the function, therefore we need to get the tendency of the function in another way
we can see that the denominator is always positive so we only care about the sign of the numerator so lets say
we can see the $$$g'(k)$$$ is always positive for all $$$ k \gt 1$$$ then we can say that $$$g(k) \gt 0$$$ for all $$$k \gt 1$$$ then $$$f'(k) \gt 0$$$ for all $$$k \gt 1$$$ then $$$f(k)$$$ always increases as we increase $$$k$$$ so the optimal value for $$$k$$$ is the smallest integer number that is greater than $$$1$$$ which turns out to be $$$2$$$ so the answer to the question I asked at the start is yes binary lifting is optimal and it turns out that I have achieved absolutely nothing new :)
it was really fun tho and I hope you like it too, even if it's completely useless :)







