Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alphabetical sort of characters within a string.
#45
What I have managed to do for my anagram finder to speed things up a whole lot is to have a the big word list, also a number of smaller files, each one containing words of equal length, also matching files containing L-R sorted versions of the same words in the same order. These files are named 3,4,5 etc and 3S,4S,5S etc. When a word from the main file is read, the length of that word opens the corresponding word length file and the matching sorted word file. These are a lot shorter than the big file, so a full scan of these is way quicker than a full length file. What's more, both the equal length word file and it's corresponding sorted file are read together, so when a sorted match is found, the corresponding anagram is read directly from the equal length file. The point is, the words being tested don't have to be sorted repeatedly on the fly, this is already done and stored in the sorted file. Edit -> These changes have sped things up by a factor of 9.2 times.
Reply


Messages In This Thread
RE: Alphabetical sort of characters within a string. - by Circlotron - 04-27-2024, 06:29 AM



Users browsing this thread: 6 Guest(s)