示例#1
0
 def insert(self, key, value):
     entry = BST.BSTNode(key, value)
     if not self.root:
         self.root = entry
     x = self.insertOps(entry, self.root)
     try:
         print("x key : ", x.key, ", x dad key : ", x.parent.key)
     except AttributeError:
         print("root key : ", x.key)
     while x != self.root:
         self.splay(x)
         self.inOrder()
     return x
示例#2
0
import BinarySearchTree as BST

node1 = BST.BSTNode()
print(node1)
node1.set_value(1)
print(node1.get_value())

node2 = BST.BSTNode(2)
node2.set_parent(node1)
node1.set_right_child(node2)
print(node2)