A basic spell checker backed by a binary search tree. You must provide missing BST implementation to make the spell checker function correctly!
-
src/main/java/Spellcheck.java
contains the main spell checker. Read over this code to familiarize yourself with how the spell checker works. -
src/main/java/BstMap.java
contains a dictionary ADT backed by a binary search tree. Note the innerNode
class is missing implementations forinsert
,find
, andremove
. Familiarize yourself with the code in this file. -
Note that keys in
BstMap
are required to implement theComparable<T>
interface. Recall that this interface provides acompareTo(T other)
method such that:x.compareTo(y) == 0
if x == yx.compareTo(y) < 0
if x < yx.compareTo(y) > 0
if x > y
-
Implement
BstMap.Node.find(...)
. -
Implement
BstMap.Node.insert(...)
. -
The spell checker should function with only
find
andinsert
are implemented. Test it:cd src/main/java javac Spellcheck.java && java Spellcheck "It was the best of times, it was the blurst of times."
What did you observe? If your implementation failed to report a result or triggered a stack overflow error, why do you think this happened?
-
If your test from exercise 3 did not work properly, identify and implement a fix. If it did work properly, print the tree structure to a depth of 20 using
BstMap.Node.printKeys(...)
. What do you notice about the structure? -
What is the big-O of
find
andinsert
in the worst case? In the average case? -
(If time allows) Implement
BstMap.Node.remove(...)
. Test your implementation by removing words from the dictionary and verifying the appropriate misspellings are reported.