Finite state machines as data structure for representing ordered sets and maps
Also called DAWGs (Directed Acyclic Word Graphs [1]).  John Resig blogged about a similar problem 5 years ago, for which I wrote a JavaScript solution [2].<p>[1] <a href="https://en.m.wikipedia.org/wiki/Directed_acyclic_word_graph" rel="nofollow">https://en.m.wikipedia.org/wiki/Directed_acyclic_word_graph</a><p>[2] <a href="https://github.com/mckoss/lookups" rel="nofollow">https://github.com/mckoss/lookups</a>