PYTHON class BSTnode: def __init__(self, key = None, left = None, right = None, parent = None): # Initialize the a node. self.__key = key # value for the node self.__left = left self.__right = right self.__parent = parent def setkey(self, newkey): # Sets the key value of the node to newkey ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code ####################################################################### def getkey(self): # returns the key value of the node ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code ####################################################################### def getright(self): # returns the right child of the node ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code ####################################################################### def setright(self, newright): # Sets the right child to the new node object newright. Child nodes parent is also updated. ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code ####################################################################### def getleft(self): # returns the left child of the node. ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code ####################################################################### def setleft(self, newleft): # Sets the left child to the new node object newleft. Child nodes parent is also updated. ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code ####################################################################### def getparent(self): # returns the parent of the node ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code ####################################################################### def setparent(self, newparent, left = True): # Sets the parent to the new node object newparent. Parents child pointer is also updated based on the value of the left. If left = True then sets node as left child of parent, sets as right child otherwise. ####################################################################### # Remove the pass and write your code ####################################################################### pass ####################################################################### # End code #######################################################################
PYTHON
class BSTnode:
def __init__(self, key = None, left = None, right = None, parent = None):
# Initialize the a node.
self.__key = key # value for the node
self.__left = left
self.__right = right
self.__parent = parent
def setkey(self, newkey):
# Sets the key value of the node to newkey
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################
def getkey(self):
# returns the key value of the node
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################
def getright(self):
# returns the right child of the node
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################
def setright(self, newright):
# Sets the right child to the new node object newright. Child nodes parent is also updated.
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################
def getleft(self):
# returns the left child of the node.
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################
def setleft(self, newleft):
# Sets the left child to the new node object newleft. Child nodes parent is also updated.
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################
def getparent(self):
# returns the parent of the node
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################
def setparent(self, newparent, left = True):
# Sets the parent to the new node object newparent. Parents child pointer is also updated based on the value of the left. If left = True then sets node as left child of parent, sets as right child otherwise.
#######################################################################
# Remove the pass and write your code
#######################################################################
pass
#######################################################################
# End code
#######################################################################

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images









