Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nikhilc2710
Created October 30, 2020 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhilc2710/8e6b1580a4ae69e8a059e6a4c2a74c9e to your computer and use it in GitHub Desktop.
Save nikhilc2710/8e6b1580a4ae69e8a059e6a4c2a74c9e to your computer and use it in GitHub Desktop.
def postorder(root,visited):
if root: #check if node exits
visited=postorder(root.left,traversal) #go to left subtree (L)
visited=postorder(root.right,traversal) #go to right subtree (R)
visited.append(root.data) #append node value to visted stack (V)
return visited #return visited stack
preorder(root,[]) #call postorder function with visited stack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment