-
Notifications
You must be signed in to change notification settings - Fork 0
/
trietest.py
87 lines (79 loc) · 2.07 KB
/
trietest.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
from trie import Trie
from compressed_trie_4 import CompressedTrie4
t = CompressedTrie4()
# t.insertWord('see')
# t.insertWord('bear')
# t.insertWord('sell')
# t.insertWord('stock')
# t.insertWord('bull')
# t.insertWord('buy')
# t.insertWord('bid')
# t.insertWord('hear')
# t.insertWord('bell')
# t.insertWord('stop')
# # lev 1
# print("---Livello 1---")
# for i in t._root._children:
# print(i)
# # lev 2
# print("---Livello 2---")
# for i in t._root._children['s']._children:
# print(i)
# for i in t._root._children['b']._children:
# print(i)
# for i in t._root._children['hear$']._children:
# print(i)
# # lev 3
# print("---Livello 3---")
# for i in t._root._children['s']._children['e']._children:
# print(i)
# for i in t._root._children['s']._children['to']._children:
# print(i)
# for i in t._root._children['b']._children['e']._children:
# print(i)
# for i in t._root._children['b']._children['u']._children:
# print(i)
# for i in t._root._children['b']._children['id$']._children:
# print(i)
# t = Trie()
t.insertWord('bear')
t.insertWord('bell')
t.insertWord('bid')
t.insertWord('bull')
t.insertWord('buy')
t.insertWord('sell')
t.insertWord('stock')
t.insertWord('stoppati')
t.insertWord('stop')
t.printTrie()
# # lev 1
# print("---Livello 1---")
# for i in t._root._children:
# print(i)
# # lev 2
# print("---Livello 2---")
# for i in t._root._children['b']._children:
# print(i)
# print('---')
# for i in t._root._children['s']._children:
# print(i)
# # lev 3
# print("---Livello 3---")
# for i in t._root._children['b']._children['e']._children:
# print(i)
# print('---')
# for i in t._root._children['b']._children['id$']._children:
# print(i)
# print('---')
# for i in t._root._children['b']._children['u']._children:
# print(i)
# print('---')
# for i in t._root._children['s']._children['ell$']._children:
# print(i)
# print('---')
# for i in t._root._children['s']._children['to']._children:
# print(i)
# # lev 4
# print("---Livello 4---")
# for i in t._root._children['s']._children['to']._children['p']._children:
# print(i)