algorithm - Link Tree nodes at each level -
Given a binary tree, how would you include nodes at each level, say left to right, at Level 3 5 nodes, link all of them from left to right.
I do not need anyone to write code for this .. But just a skilled algorithm
Create a vector of linked lists. Keep track of keeping your DFS one level, and add whatever you find for each node, to the level linked list. It will run in O (N) which is optimal.
Do you want to do this?
Comments
Post a Comment