Skip to content

Commit 41875ac

Browse files
committed
docs: Add comment for clarity
1 parent 0e45116 commit 41875ac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/java/dataStructures/trie/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Like most trees, a trie is composed of nodes and edges. But, unlike binary trees
88
2 children. A trie stores words by breaking down into characters and organising these characters within a hierarchical
99
tree. Each node represents a single character, except the root, which does not represent any character
1010
but acts as a starting point for all the words stored. A path in the trie, which is a sequence of connected nodes
11-
from the root, represents a prefix or a whole word. Shared prefixes of different words are represented by common paths.
11+
from the root, represents a prefix or a whole word. Shared prefixes of different words are represented by common paths.
12+
1213
To distinguish complete words from prefixes within the trie, nodes are often implemented with a boolean flag.
1314
This flag is set to true for nodes that correspond to the final character of a complete word and false otherwise.
1415

src/main/java/dataStructures/trie/Trie.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public Trie() {
1515
root = new TrieNode();
1616
}
1717

18+
/**
19+
* TrieNode implementation. Note, fields are set to public for decreased verbosity.
20+
*/
1821
private class TrieNode {
1922
// CHECKSTYLE:OFF: VisibilityModifier
2023
public Map<Character, TrieNode> children; // or array of size 26 (assume not case-sensitive) to denote each char

0 commit comments

Comments
 (0)