Visualize a tree: Difference between revisions

m
m (Added output.)
Line 1,947:
─ 0 ─┤ ┌─ 4 ─┴─ 9
└─ 2 ─┴─ 5 </lang>
 
For comparison purposes, here's the node labels along with (in the following row) the index of their parent node:
 
<lang j> (i.10),: _,}.p:inv i.10
0 1 2 3 4 5 6 7 8 9
_ 0 0 1 2 2 3 3 4 4</lang>
 
Also, note that labels can be arbitrary. Here, we used numeric labels because they were concise and convenient. But, for example, we can replace the label '0' with 'george' and the label '4' with 'fred':
 
<lang j> ((<'george') 0} (<'fred') 4} ":each i.10)showtree _,}.p:inv i.10
┌─ 6
┌─ 1 ─── 3 ────┴─ 7
│ ┌─ 8
─ george ─┤ ┌─ fred ─┴─ 9
└─ 2 ─┴─ 5 </lang>
 
=={{header|Java}}==
6,962

edits