Skip to content

Instantly share code, notes, and snippets.

@nikhilc2710
Last active October 30, 2020 07:16
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/28c860a84fcee2f614b79ad1f6f61b7b to your computer and use it in GitHub Desktop.
Save nikhilc2710/28c860a84fcee2f614b79ad1f6f61b7b to your computer and use it in GitHub Desktop.
def inorder(root,visited):
if root: #check if node exits
visited=inorder(root.left,traversal) #go to left subtree (L)
visited.append(root.data) #append node value to visted stack (V)
visited=inorder(root.right,traversal) #go to right subtree (R)
return visited #return visited stack
inorder(root,[]) #call inorder function with visited stack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment