Created
May 31, 2014 13:13
-
-
Save wethinkagile/1a96ca0e056a5e968c1c 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
class BinaryTree: | |
def __init__(self,rootObj): | |
self.key = rootObj | |
self.leftChild = None | |
self.rightChild = None | |
def getRightChild(self): | |
return self.rightChild | |
def getLeftChild(self): | |
return self.leftChild | |
def getRootVal(self): | |
return self.key | |
def setRootVal(self,obj): | |
self.key = obj | |
def insertLeft(self,newNode): | |
if self.leftChild == None: | |
self.leftChild = BinaryTree(newNode) | |
else: | |
temp = BinaryTree(newNode) | |
temp.leftChild = self.leftChild | |
self.leftChild = temp | |
def insertRight(self,newNode): | |
if self.rightChild == None: | |
self.rightChild = BinaryTree(newNode) | |
else: | |
temp = BinaryTree(newNode) | |
temp.rightChild = self.rightChild | |
self.rightChild = temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment