what is the meaning of F[n-1:0] ? i understand how how it changes the output, but I don’t understand its logical meaning and what its connection to grey code?
Great question! You can think about f as the point and direction of reflection of the Gray code, or equivalently, the direction of the Hamiltonian path across the hypercube.
The Hamiltonian path over an n-dimensional hypercube can be decomposed into two sub-paths, p_{n - 1} and q_{n - 1} as given in Algorithm 1. f[n - 1] determines which sub-path is taken first when walking over the Hamiltonian path. Similarly, the other bits of f affect the same decision, but at different “decomposition levels”.
It is hard to explain briefly in text, but I suggest you draw out a 3D hypercube and go through the algorithm step-by-step. Let me know if you cannot see this ordering property, and I will try to make a graphic explaining it.