Skip to content

feat: add trie data structure - #303

Open
CapedCrusader77 wants to merge 1 commit into
TheAlgorithms:masterfrom
CapedCrusader77:add-trie
Open

CapedCrusader77 wants to merge 1 commit into
TheAlgorithms:masterfrom
CapedCrusader77:add-trie

Conversation

@CapedCrusader77

Copy link
Copy Markdown

Adds data_structures/trie.r: insert, search, prefix check, delete with pruning, autocomplete, plus example tests.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 06:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Prefix collection performs quadratic character copying instead of the documented linear work, and the new trie is missing from the algorithm index.

2 open issues

Review effort: Balanced

Comment thread data_structures/trie.r
Comment on lines +119 to +129
trie_collect <- function(node, prefix) {
results <- character(0)
if (node$is_end) {
results <- c(results, prefix)
}
for (ch in sort(ls(node$children, all.names = TRUE))) {
child <- get(ch, envir = node$children, inherits = FALSE)
results <- c(results, trie_collect(child, paste0(prefix, ch)))
}
results
}
Comment thread data_structures/trie.r
Comment on lines +1 to +3
# A trie (prefix tree) stores strings so that words sharing a prefix share
# the same path from the root. Each node holds one child per character and a
# flag marking the end of a word.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants