Ask Your Question

Revision history [back]

You should have a look at LabelledBinaryTree

sage: t1 = LabelledBinaryTree([None, None], label=3)
sage: t2 = LabelledBinaryTree([None, None], label=4)
sage: t = LabelledBinaryTree([t1,t2], label=-2)
sage: t
-2[3[., .], 4[., .]]

And easier to read

sage: ascii_art(t)
  -2
 /  \
3    4