Tag Info

New answers tagged


In the algorithm you provided, although it is true that the same in-order operation is performed in the same node multiple times, it is still ran once for each node and each node is visited only once. Note that this isn't a "in-order" tree traversal, you can't make such a traversal on a ntree, it just doesn't make sense. This is simply a deep-first ...


I would check out http://www.fusu.us/2013/07/printing-binary-tree-boundary.html. It uses additional data structures but is but runs in linear time with a single traversal. The stacks used in the linked solution would not be necessary if you were not worried about the order in which the boundary is printed. In this case you could do your favorite linear tree ...

Top 50 recent answers are included