p[i][j]= T[i] j=0;
P[P[i][j-1]][j-1] j>0
where p[i][j] is the 2^j th ancestor of i
i can’t understand this can anyone explain in detail?
thanks in advance?
p[i][j]= T[i] j=0;
P[P[i][j-1]][j-1] j>0
where p[i][j] is the 2^j th ancestor of i
i can’t understand this can anyone explain in detail?
thanks in advance?
I assume you took this from TC tutorial.
Take a look at this figure once again. 10 is the 1st ancestor of 12, 7 is the second, and 1 is the 4th.
So, for i = 12, P[12][0] = 10, P[12][1] = 7, and P[12][2] = 4, the 2^j th ancestor.
You can try this with a bigger tree, and use the code provided to obtain the values for P, things will become clear.