Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 62bb4d3 commit 91eecf3Copy full SHA for 91eecf3
src/graph/lca_binary_lifting.md
@@ -28,7 +28,7 @@ We will describe this process in more detail.
28
Let `L = ceil(log(N))`.
29
Suppose first that `i = L`.
30
If `up[u][i]` is not an ancestor of `v`, then we can assign `u = up[u][i]` and decrement `i`.
31
-If `up[u][i]` is not an ancestor, then we just decrement `i`.
+If `up[u][i]` is an ancestor, then we just decrement `i`.
32
Clearly after doing this for all non-negative `i` the node `u` will be the desired node - i.e. `u` is still not an ancestor of `v`, but `up[u][0]` is.
33
34
Now, obviously, the answer to LCA will be `up[u][0]` - i.e., the smallest node among the ancestors of the node `u`, which is also an ancestor of `v`.
0 commit comments