Skip to content

Instantly share code, notes, and snippets.

@mgarod
Created January 12, 2016 21:08
Show Gist options
  • Save mgarod/10ef934583981052e6bf to your computer and use it in GitHub Desktop.
Save mgarod/10ef934583981052e6bf to your computer and use it in GitHub Desktop.
def insert(self, d):
if self.head is None:
self.head = Node(d)
else:
self.insert_helper(self.head, d)
def insert_helper(self, nd, d):
if d < nd.data:
if nd.left is None:
nd.left = Node(d)
else:
self.insert_helper(nd.left, d)
else:
if nd.right is None:
nd.right = Node(d)
else:
self.insert_helper(nd.right, d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment