I have to find all of the compound words in a text file. This file contains almost 200,000 words and I am trying to implement this in the least amount of time.
So for example, the text file contains the words fire, house, and firehouse. Firehouse would be considered a compound word and would be added to a different text file displayed as "fire-house".
What is the best data structure or implementation that I can use to find all of these compound words in the fastest time?
Any tips or help is appreciated.
I've tried doing some stuff, but when I run the program, it takes forever.
I need an algorithm that runs in linear time.