Skip to content

Commit ed4bf48

Browse files
Alex de la CruzAlex de la Cruz
Alex de la Cruz
authored and
Alex de la Cruz
committed
solved flake8
1 parent b691fa3 commit ed4bf48

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

data_structures/trie/radix_tree.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
2-
A Radix Tree is a data structure that represents a space-optimized trie (prefix tree) in which
3-
each node that is the only child is merged with its parent [https://en.wikipedia.org/wiki/Radix_tree]
2+
A Radix Tree is a data structure that represents a space-optimized
3+
trie (prefix tree) in whicheach node that is the only child is merged
4+
with its parent [https://en.wikipedia.org/wiki/Radix_tree]
45
"""
56

67

@@ -60,7 +61,8 @@ def insert(self, word: str) -> None:
6061
self.is_leaf = True
6162

6263
# Case 2: The node has no edges that have a prefix to the word
63-
# Solution: We create an edge from the current node to a new one containing the word
64+
# Solution: We create an edge from the current node to a new one
65+
# containing the word
6466
elif word[0] not in self.nodes:
6567
self.nodes[word[0]] = RadixNode(prefix=word, is_leaf=True)
6668

@@ -76,7 +78,8 @@ def insert(self, word: str) -> None:
7678
self.nodes[matching_string[0]].insert(remaining_word)
7779

7880
# Case 4: The word is greater equal to the matching
79-
# Solution: Create a node in between both nodes, change prefixes and add the new node for the remaining word
81+
# Solution: Create a node in between both nodes, change
82+
# prefixes and add the new node for the remaining word
8083
else:
8184
incoming_node.prefix = remaining_prefix
8285

@@ -173,7 +176,7 @@ def print_tree(self, height=0) -> None:
173176
"""Print the tree
174177
175178
Args:
176-
height (int, optional): Height of the node that is being printed. Defaults to 0.
179+
height (int, optional): Height of the printed node
177180
"""
178181
if self.prefix != "":
179182
print("-" * height, self.prefix, " (leaf)" if self.is_leaf else "")

0 commit comments

Comments
 (0)