There was an error while loading. Please reload this page.
1 parent ff5b7fe commit 4b2c606Copy full SHA for 4b2c606
1 file changed
data_structures/trie/radix_tree.py
@@ -198,6 +198,21 @@ def print_tree(self, height: int = 0) -> None:
198
value.print_tree(height + 1)
199
200
201
+def test_trie() -> None:
202
+ words = "banana bananas bandana band apple all beast".split()
203
+ root = RadixNode()
204
+ root.insert_many(words)
205
+
206
+ assert all(root.find(word) for word in words)
207
+ assert not root.find("bandanas")
208
+ assert not root.find("apps")
209
+ root.delete("all")
210
+ assert not root.find("all")
211
+ root.delete("banana")
212
+ assert not root.find("banana")
213
+ assert root.find("bananas")
214
215
216
class TestRadixNode(unittest.TestCase):
217
def test_trie(self) -> None:
218
words = "banana bananas bandana band apple all beast".split()
0 commit comments