csnotes/370/notes/tries.md
Medium Fries ea2aa8d2a6 yote
2019-03-15 01:26:26 -07:00

1.0 KiB

Tries - Prefix Trees(syntax trees in disguise)

We can build grammers from symbols where symbols follow a set of rules to build on each other. Kinda like linguistic sytax trees but, exactly the same. Individual syntaxes are combined to build grammers combine to build phrases, etc. etc.

Instead of symbols we use prefixes as our terminology, to build words. Terminally sequenced symbols are denoted by a leaf flag.

Deletion

We don't actually remove things for trivial cases. Instead we turn off the leaf flag in the end target node

if we have /bathe/ and /bathes/ as valid phrases and wanted to remaove /bathe/ from our language * All we have to do is set the /e/ to off as a valid leaf.

If instead we wanted to remove /bathes/ instead we would go to /s/ and then set it to off like before. * The problem now is that /s/ is hanging and it doesn't have any children so we can remove it entirely * If a toggled off node has children it means that it necessarily is part of a valid prefix so it can not be removed