Skip to content

Commit

Permalink
src: fix formatting in dat.c
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Aug 25, 2024
1 parent 95186fe commit 9d4eedc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fundamentals/datastructures/src/dat.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ void insert(trie_dat* trie, const char* word) {
int char_offset = word[i] - 'a';

ensure_capacity(trie, cur_node);

if (trie->base[cur_node] == 0) {
// base[cur_node] is the offset for the current node in the
// array. This is setting it to the current node in the trie which
// is trie->size. We can think of this as setting this index/offset
// to the current node int tree. I thought this was strange that we
// use the size but perhaps we can think of it as the depth of the
// tree where we currently are. Like get go from
// to the current node in the tree. I thought this was strange that
// we use the size but perhaps we can think of it as the depth of
// the tree where we currently are. Like get go from
// ROOT -> 'c' -> 'o" -> 'w'
// 0 -> 1 -> 2 -> 3 (size)
trie->base[cur_node] = trie->size;
Expand All @@ -61,6 +62,7 @@ void insert(trie_dat* trie, const char* word) {
int t = trie->base[cur_node] + char_offset;

ensure_capacity(trie, t);

if (trie->check[t] == 0) {
trie->check[t] = cur_node;
trie->size++;
Expand Down

0 comments on commit 9d4eedc

Please sign in to comment.