At the end of the video,for n - ary tree finding lca why do we need n sized array in custom class ? we just need two varibles? can you please provide solution for n - ary tree problem?
N ary tree case
@sahazeer123 see the code don’t made to stick on 2 calls left or right
it don’t take into account how many children are there
code can be applied to genric tree as well
but the problem is for genric tree there may be more than two haskeys
so that’s why we have to make an n sized arry to solve it for genric tree
Please explain why there would be more than two haskeys in n - ary tree?
so @sahazeer123
there is nothing such as n-arry tree
we are taking about genric tree in which we have to make an array of n size
why??
because as for binary tree we have two hashkey one from left and other from right in the same way for
genric tree there may be n childrens for there may be n hashkeys that’s why we have to make n sized array to find LCA for genric tree
question is for binary tree and we solved it for binary tree
if your doubt is resolved Please mark it as resolved
if you have any doubt regarding this feel free to ask
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.