self.inorder(noda.rchild)
def preorder(self,noda):
if noda!=None:
print (" %d " % noda.data)
self.preorder(noda.lchild);
self.preorder(noda.mchild)
self.preorder(noda.rchild)
def postorder(self,noda):
if noda!=None:
self.postorder(noda.lchild);
self.postorder(noda.mchild)
self.postorder(noda.rchild)
print (" %d " % noda.data)
//daraxtni hosil qilish
t = Tree()
t.root = t.my_insert(t.root,1,0)
t.node_2 = t.my_insert(t.root,2,0);
t.node_3 = t.my_insert(t.root,3,1);
t.node_4 = t.my_insert(t.root,4,2);
t.node_5 = t.my_insert(t.node_3,5,0);
t.node_8 = t.my_insert(t.node_5,8,0);
Do'stlaringiz bilan baham: |