Skip to content

Commit

Permalink
docs: add more trie notes (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Aug 23, 2024
1 parent 016fefa commit dac4fd7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions notes/trie.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,24 @@ BASE[1] = 2 - 97 = -95
BASE[0] = -98
BASE[1] = -95
```
The base array is used for navigating from one node to another node based on the
input characters.
base[current_node] gives us the base index/offset for navigating from the current
node to its children. This is then used with an offset, another character in the
input. The offset is the ASCII value of the character.
So base[current_node] represents the offset in the array where the transistions
from the current node start.
```
0(root)
|
1(c)
/ \
2(a) 3(o)
| |
4(t*) 5(w*)
```
_wip_

0 comments on commit dac4fd7

Please sign in to comment.