In computer science, a trie, also called digital tree and sometimes radix tree or prefix tree (as they can be searched by prefixes), is an ordered tree data structure that is used to store a dynamic set or associative array where the keys are usually strings. Unlike a binary search tree, no node in the tree stores the key associated with that node; instead, its position in the tree defines the key with which it is associated. All the descendants of a node have a common prefix of the string associated with that node, and the root is associated with the empty string. Values are not necessarily associated with every node. Rather, values tend only to be associated with leaves, and with some inner nodes that correspond to keys of interest. For the space-optimized presentation of prefix tree, see compact prefix tree.
In the example shown, keys are listed in the nodes and values below them. Each complete English word has an arbitrary integer value associated with it. A trie can be seen as a tree-shaped deterministic finite automaton. Each finite language is generated by a trie automaton, and each trie can be compressed into a deterministic acyclic finite state automaton.
I love You, Lord, I worship You
I love You, Lord, always
So thankful Lord, You saved my life
You saved my life today
Let me be a shining light for You
Let me be a joy to You always
Let me be a shining light for You
Let me be a joy to You always, yeah, yeah
No Superman, I'm no hero
I'm just a man in Your eyes
But through Your son I've overcome
The Father of all lies
Let me be a shining light for You
Let me be a joy to You always
Let me be a shining light for You
Let me be a joy to You always, yeah, yeah, yeah
Hallelujah, Hallelujah
Hallelujah, Hallelujah
No Superman, I'm no hero
I'm just a man in Your eyes
But through Your son I've overcome
The Father of all lies
Let me be a shining light for You
Let me be a shining light for You
Let me be a joy to You always
Let me be a shining light for You
Let me be a joy to You always
Let me be a shining light for You
Let me be a joy to You always
Let me be a shining light for You
Let me be a joy to You always
Let me be a joy to You always
Let me be a joy to You always
I wanna be a joy to You always
Let me be a joy to You always
Hallelujah, Hallelujah