-
Notifications
You must be signed in to change notification settings - Fork 0
/
binarySearchTree_test.py
55 lines (42 loc) · 992 Bytes
/
binarySearchTree_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from os import remove
from binarySearchTree import BinarySearchTree
def printNodeData(treeNode):
print(treeNode.data)
def __yield_method(node):
# yield node.data
print(node.data)
bTree = BinarySearchTree()
# bTree.add(9)
# bTree.add(3)
# bTree.add(2)
# bTree.add(1)
# bTree.add(4)
# bTree.add(7)
# bTree.add(6)
bTree.add(50)
bTree.add(25)
bTree.add(20)
bTree.add(30)
bTree.add(10)
bTree.add(15)
bTree.add(100)
bTree.add(80)
bTree.add(60)
bTree.add(70)
bTree.add(200)
bTree.add(180)
bTree.add(160)
bTree.add(165)
bTree.add(190)
bTree.add(300)
# print(bTree.root.left.left.left.data) #Should be 1
# print(bTree.root.left.right.data) # Should be 4
# bTree.pre_order_traversal(printNodeData)
# bTree.in_order_traversal(printNodeData)
# bTree.post_order_traversal(printNodeData)
# bTree.remove(50)
# for data in bTree:
# print(data)
(node, parent) = bTree.findWithParent(100)
# print(bool(parent) ^ bool(node))
print(None if parent is None else parent.data, node.data)