c++ - Printing Tree Vertically -


Any idea how to print a tree like this?

  2 / \ / \ / \ / \ 7 5 / \ \ / \ 2 6 9 / \ / 5 8 4  

Horizontal solution works well because you use deep search (as you've shown) to create a tree from each subtitle. , Which the console aligns well in the form of a line at a time.

The vertical solution is more difficult, because you need to know all the nodes at the end of the tree to calculate the full width. Therefore, you need to analyze the tree, collect data and then start plotting.

The second option, though perhaps not "elegant" (based on definition), would be to use something like a curses library, in which the performance columns and rows have interchangeable concepts.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -