<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#3333ff">
<font size="+1">Kent,<br>
<br>
Thank you for two excellent suggestions. I will implement your&nbsp;
suggestion of indexing by the sorted letters in the word.<br>
<br>
Robert<br>
</font><br>
Kent Johnson wrote:
<blockquote
 cite="mid:1c2a2c590810051154j5d0fac89x539190ace8a6685f@mail.gmail.com"
 type="cite">
  <pre wrap="">On Sun, Oct 5, 2008 at 1:52 PM, Robert Berman <a class="moz-txt-link-rfc2396E" href="mailto:bermanrl@embarqmail.com">&lt;bermanrl@embarqmail.com&gt;</a> wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">The database item consists of the key; the actual word, and the value, the
size as a string. For example, the word 'myth' is represented as key=
'myth', value = '4'.  I think the slow part of the algorithm is the script
retrieves a list of all database words of length (myth)=4. That's a lot of
words. Each word is sorted  and then compared to the alpha sorted word. When
there is a match, that word becomes a part of the anagram list. Even a very
basic look at the word 'myth' shows there are no anagrams. So, to return an
empty list, we have scanned all words in the database of size 4.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
This is pretty inefficient, yes. You actually scan every word in the
database because you have to find the ones of length 4. You are really
using the database as just a list of words. A better data structure
would be to index by word length with the value being a list of words
of that length. Even better would be to index by the sorted letters in
the word, with the value being a list of all words with that sorting.

Kent

  </pre>
</blockquote>
</body>
</html>