oday
05/19/2023, 9:20 AM235,000
words from a file and search through them I have also stored the same number of words in an ArrayList, so that I could compare.
the way I search within the Trie is using the prefix matching algorithm, the way I search within the ArrayList is list.filter { it.startsWith(input) }
and then I measure the output, the Trie is always slower, always. I run a similar program written in Python that does the same thing, the trie is always faster, always. What's going on?
Trie implementation: https://hastebin.com/share/warefekava.kotlin
Main.kt: https://hastebin.com/share/baxuzonuti.kotlin
Words: you can ls /usr/share/dict/words
if you are on Mac or Linux
Python script (trie impl and matcher): https://hastebin.com/share/ezokubugix.pythonoday
05/19/2023, 9:24 AModay
05/19/2023, 10:41 AMPaul Griffith
05/19/2023, 4:30 PMPaul Griffith
05/19/2023, 4:31 PMPaul Griffith
05/19/2023, 4:33 PMinline
oday
05/19/2023, 8:34 PModay
05/19/2023, 8:34 PModay
05/19/2023, 8:34 PModay
05/20/2023, 8:38 AM