Print a binary tree in a pretty way

后端 未结 15 1312
我寻月下人不归
我寻月下人不归 2020-11-28 22:15

Just wondering if I can get some tips on printing a pretty binary tree in the form of:

5
     10
          11
          7
               6
     3
          4         


        
15条回答
  •  生来不讨喜
    2020-11-28 22:48

    If your only need is to visualize your tree, a better method would be to output it into a dot format and draw it with grapviz.

    You can look at dot guide for more information abt syntax etc

提交回复
热议问题