vedant1771 / Hactoberfest2021

Repository for Hactoberfest2021
34 stars 464 forks source link

traversal of bst (python) #477

Open drashtipatel2503 opened 3 years ago

drashtipatel2503 commented 3 years ago

will add inorder, preorder, postorder and level order traversal in python

prakharsaxena786 commented 3 years ago

i want to solve this issue, as i learnt python and having the skill of doing problem-solving in python.

Akhilendra-Mishra commented 3 years ago

class Node: def init(self, key): self.left = None self.right = None self.val = key

def printInorder(root):

if root:

    printInorder(root.left)

    print(root.val),

    printInorder(root.right)

def printPostorder(root):

if root:

    printPostorder(root.left)

    printPostorder(root.right)

    print(root.val),

def printPreorder(root):

if root:

    print(root.val),

    printPreorder(root.left)

    printPreorder(root.right)

root = Node(1) root.left = Node(2) root.right = Node(3) root.left.left = Node(4) root.left.right = Node(5) print "Preorder traversal of binary tree is" printPreorder(root)

print "\nInorder traversal of binary tree is" printInorder(root)

print "\nPostorder traversal of binary tree is" printPostorder(root)

abhishek-sengar commented 2 years ago

can i work on this issue

sp-gits commented 2 years ago

Please assign me this issue

bong-engineer commented 2 years ago

please assign me this issue