In this implementation we have 2 classes:
PrefixTree
BoggleBoard
PrefixTree
class essentially implements the Trie data structure.
BoggleBoard
class aims at solving the Boggle Board that has been generated.
Memeber functions in class PrefixTree
:
__init__
: Constructor that helps in defining the basic structure of the Trie nodeinsert
: Add every letter of every word into the Trie data structurefind_children
: Returns letters connected to a specific letter aka, it's children
Memeber functions in class BoggleBoard
:
__init__
: Constructor that helps in creating a randomized word of givne size (default min: 3)solve_boggle
: Basically, callsearch_tree
for every index in the boggle boardsearch_tree
: Implements DFS to search for the word in Trie
We have other helper functions such as:
load_word_list
: This loads the entire word list / dictionary into memory and we insert each word into Trie.run_benchmark
: Helps in calculating how long it takes to solve for varying board sizes.