-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
101 lines (80 loc) · 2.16 KB
/
main.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/python
from DataStructure import BinaryTree
from DataStructure import HashTable
from Algorithm import BinarySearch
from Algorithm import DepthFirstSearch
from DataStructure import Vector
from Algorithm import QuickSort
from DataStructure import avl_tree
from Algorithm import tower_of_hanoi
from Algorithm import pascal_formula
def test_quick_sort():
a = [9, 8, 7, 6, 5, 4, 3, 2, 1]
QuickSort.quick_sort(a, 0, len(a)-1)
for i in a:
print str(i)
def test_hash_table():
hash_table = HashTable.HashTable(100)
print "hash key(10): " + str(hash_table.hash_table_put(10))
print "hash key(100):" + str(hash_table.hash_table_put(100))
print "hash key(1000):" + str(hash_table.hash_table_put(1000))
print "hash key(10000):" + str(hash_table.hash_table_put(10000))
print hash_table.hash_table_is_in_table(199)
print hash_table.hash_table_get_by_key(0)
print hash_table.hash_table_get_by_key(0)
def test_binary_search():
l = [2, 4, 6, 8, 10]
bs = BinarySearch.binary_search(l, 2)
print str(bs)
def test_depth_first_search():
stack = DepthFirstSearch.Stack()
stack.push(1)
stack.push(2)
stack.push(3)
stack.show()
def test_vector():
v = Vector.Vector()
v.add(1)
v.add(2)
v.add(3)
v.insert(3, 10)
print ""
print v.get(3)
print ""
v.print_all()
v.insert(10, 100)
print ""
v.print_all()
v.insert(6, 99)
print ""
v.print_all()
print ""
v.remove(2)
v.remove(0)
v.print_all()
def test_binary_tree():
bt = BinaryTree.BinaryTree()
data = [50, 20, 90, 10, 30, 70, 100, 5, 15, 25, 40, 60, 80, 95, 101]
for d in data:
bt.insert(int(d))
array = []
bt.show(array)
for i in array:
print str(i)
bt.remove(20)
array2 = []
bt.show(array2)
for i in array2:
print str(i)
def main():
# test_binary_tree()
# Recursion.test_fibonacci()
# test_quick_sort()
# test_hash_table()
# test_binary_search()
# test_depth_first_search()
# avl_tree.test_avl_tree()
# tower_of_hanoi.test_hanoi(3)
print pascal_formula.factorial(5)
if __name__ == '__main__':
main()