words..

Started by
5 comments, last by Fruny 19 years, 8 months ago
I'm making a program which requires to search through a list of words....in needs to search through all the words in the dictionary. What would be the fastest way to search through all the words. Also, where can i get a list of all the words in the dictionary? (i did try google)
Advertisement
#1. Well, I would probably make a tree where each node has 26 children, one corresponding to each letter, then just follow the tree down. That way access to a word is O(n) where n is the number of letters in the word.

#2. I don't know, but I'm willing to bet you could get one out of Open-Office (an open source office suite including a word processer with spell checking) if you tried hard enough.


"There is no dark side of the moon really,
As a matter of fact, its all dark."
i know where you can find a large word list like that. any sort of hacking underground site will have dictionaries like that, that you can just download in plain text. i think they're used for brute force cracking programs or something.
Quote:Original post by yves032784
Also, where can i get a list of all the words in the dictionary? (i did try google)


http://www.google.com/search?hl=en&lr=&ie=UTF-8&q=plain-text+dictionary+download&btnG=Search

-me
You sould be able to find some freely available plain text dictionary easily with google. In fact it appears that someone beat me to a link.

You question is however too vague. In order to get the best solution you must provide more info.
How often do you need to search through the dictionary?
What are you searching for?

There could be a ton of reasons for using a dictionary e.g. spell checking, finding a random N-letter word for a word game, finding possible words for a crossword solver, generating a letter frequency table for compression etc etc...
All of these would each be best handled in different ways.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Have a three/four/+ dimensional array. Each letter corresponds to a number. A=0, B=1, C=2... Z=25. The first dim is the first letter. Then the second dim is the second letter of the word etc... Just like sorting.
Tries may be appropriate data structures, depending on what you want to do with the words.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement