Algorithms and Data Structures: Trie (Prefix tree)
&quot; that means 235,887 operations for each string that I want to verify as a real word.&quot;<p>&#x2F;usr&#x2F;share&#x2F;dict&#x2F;words is sorted. A binary search would be much more suitable than iterating over each word, at least for a first run.<p>And depending on the constraints of the actual problem you are trying to solve a binary search is likely going to be the best well rounded case.<p>(This mostly depends if memory and disk space constraints are in place).<p>But I would imagine most spell checkers store their dictionary much differently than that of dict&#x2F;words<p>(off to take a look at the aspell source)