Skip to content

Commit 87aec39

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 275dcfd commit 87aec39

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

data_structures/trie/radix_tree.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
trie (prefix tree) in whicheach node that is the only child is merged
44
with its parent [https://en.wikipedia.org/wiki/Radix_tree]
55
"""
6+
67
import unittest
78

9+
810
class RadixNode:
911
def __init__(self, prefix: str = "", is_leaf: bool = False) -> None:
1012
# Mapping from the first character of the prefix of the node
@@ -195,9 +197,11 @@ def print_tree(self, height: int = 0) -> None:
195197
for value in self.nodes.values():
196198
value.print_tree(height + 1)
197199

200+
198201
## write unit test for the code using unittest library with logic similar to test_trie() function
199202
## and call it from main()
200203

204+
201205
class TestRadixNode(unittest.TestCase):
202206
def test_trie(self) -> None:
203207
words = "banana bananas bandana band apple all beast".split()
@@ -212,13 +216,12 @@ def test_trie(self) -> None:
212216
root.delete("banana")
213217
self.assertFalse(root.find("banana"))
214218
self.assertTrue(root.find("bananas"))
215-
216219

217220
def test_trie_2(self) -> None:
218-
'''
219-
now add a new test case which inserts
221+
"""
222+
now add a new test case which inserts
220223
foobbb, fooaaa, foo in the given order and checks for different assertions
221-
'''
224+
"""
222225
words = "foobbb fooaaa foo".split()
223226
root = RadixNode()
224227
root.insert_many(words)
@@ -229,5 +232,6 @@ def test_trie_2(self) -> None:
229232
self.assertTrue(root.find("foobbb"))
230233
self.assertTrue(root.find("fooaaa"))
231234

235+
232236
if __name__ == "__main__":
233237
unittest.main()

0 commit comments

Comments
 (0)