Created
January 12, 2016 21:08
-
-
Save mgarod/10ef934583981052e6bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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