Find first null in binary tree with limited memory -


I have a binary tree where the value of each node can be.

If the value of the node tree is zero and the nearest of the root, if there are two nodes with the same distance from the root, what would happen if I need to reduce the number of binary trees to read That work memory is limited to only K nodes.

DFS is fully k-deep, but the closest node will not be available until I have run through the whole tree before. BFS will find the closest, but it may fail because DFS can find deep noses with the same memory.

I have the lowest number of trees to read and find the closest null node.

(I will eventually need to implement it in the N-trees also, so also, a common solution would be good. Not allowed to write the tree, just read.)

You might want to see. It will automatically find the nearest node but will be able to reach the same depth as DFS. However it will use Read More access.

You can also start with BFS, and if you are not getting a blank with acceptable memory, then run DFS.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -