in skewed tree why we have to traverse all the nodes if nodes are 5 k is 1 and target node is 2 so wehave to traverse only2 time
Nodes at distance k
hi @deepakjumani09, if you know the code then u would notice that for every node we check where node is present in left subtree or the right subtree and we recursively call to only the part of subtree in which the given node is present and leave the other unvisited but in skew tree since every node has only one subtree i. e single child thus we will have to visit all the nodes
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.