3

I am trying to make a word game in Flash/as3. Here I am using Prefix tree (Trie) data structure to store all the valid English words and then iterate through them whenever the user makes a new word.

My problem is that the build process of Trie is very slow (as there are more than 3,00,000 words in the dictionary) and so compiling it every time the user starts the game does not look like a nice idea to me.

Is there a way I could compile the code just once and store the compiled code and use it later on. Maybe in a .swc file or a .exe file or anything.

I also would like to know correct technical term for the above question. Don't require flash specific solutions. Just tell me the idea behind what needs to be done in any language.

Thanks a lot people :)

Mudit Jaju
  • 590
  • 7
  • 17

1 Answers1

1

You could generate source code from your dictionary data and compile it as part of your program. If the data changes infrequently and you keep the generated source code in a separate source file then even recompilation with make (or an equivalent) should be fast once you've compiled the generated source code once.

Alexey Frunze
  • 61,140
  • 12
  • 83
  • 180
  • Sorry I didn't understand ... how can I make a separate source file of just a Tree Data structure ? – Mudit Jaju Apr 08 '13 at 05:37
  • 1
    @HappyBirthday Instead of writing your trie generating algorithm to produce a data structure in memory, make it print out the source code for that data structure, so the compiler can compile it into a source file. – Patashu Apr 08 '13 at 05:40
  • Use structures, arrays, indices, pointers, all the usual stuff. – Alexey Frunze Apr 08 '13 at 05:41
  • @Patashu And if there are any pointers, they should be changed to indices. – Alexey Frunze Apr 08 '13 at 05:48
  • @AlexeyFrunze I'm pretty sure OP is using AS3, so there shouldn't be any pointers. But I also see the C++ tag, so I understand why you pointed (hehe) that out. – Rahul Banerjee Apr 08 '13 at 09:13