notes:trie
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:trie [2025/08/11 20:09] – smj-edison | notes:trie [2025/08/11 20:11] (current) – smj-edison | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Part 1: the Trie ===== | + | ===== Moved to ===== |
- | A Trie is the data structure that underlies Folk's database. It is the index to all Wishes, Claims, and Whens. The Trie works by inserting and removing Clauses. A Clause is an array of space-seperated words, with each word being called a Term. An example Clause, "the sky is blue", would become | + | Moved to [[notes:internals:trie|Part 1: the Trie]] |
- | + | ||
- | Let's insert the Clause into the Trie and see what happens: | + | |
- | + | ||
- | {{notes:pxl_20250811_192744566.jpg? | + | |
- | + | ||
- | As you can see, the Clause has been turned into a set of nodes in the Trie. Let's try inserting another Clause, "the sky has clouds": | + | |
- | + | ||
- | {{notes: | + | |
- | + | ||
- | A Trie is just a tree, with each level being one word*. | + | |
- | + | ||
- | We've now covered inserting, but what about querying? Let's try querying for "the sky has clouds" | + | |
- | + | ||
- | {{notes:trie-lookup-level-1.jpg? | + | |
- | + | ||
- | {{notes: | + | |
- | + | ||
- | {{notes: | + | |
- | + | ||
- | {{notes:trie-lookup-level-3-part-2.jpg? | + | |
- | + | ||
- | {{notes: | + | |
- | + | ||
- | Notice how we never had to check " | + | |
- | + | ||
- | + | ||
- | * Technically, | + | |
- | + |
notes/trie.txt · Last modified: by smj-edison