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

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -