Speller <---- My Project!
Theoretically, on input of size n, an algorithm with a running time of n is âasymptotically equivalent,â in terms of O, to an algorithm with a running time of 2n. Indeed, when describing the running time of an algorithm, we typically focus on the dominant (i.e., most impactful) term (i.e., n in this case, since n could be much larger than 2). In the real world, though, the fact of the matter is that 2n feels twice as slow as n.
The challenge ahead of you is to implement the fastest spell checker you can! By âfastest,â though, weâre talking actual âwall-clock,â not asymptotic, time.
In speller.c
, weâve put together a program thatâs designed to spell-check a file after loading a dictionary of words from disk into memory. That dictionary, meanwhile, is implemented in a file called dictionary.c
. (It could just be implemented in speller.c
, but as programs get more complex, itâs often convenient to break them into multiple files.) The prototypes for the functions therein, meanwhile, are defined not in dictionary.c
itself but in dictionary.h
instead. That way, both speller.c
and dictionary.c
can #include
the file. Unfortunately, we didnât quite get around to implementing the loading part. Or the checking part. Both (and a bit more) we leave to you!
Example
Implement a program that spell-checks a file, a la the below, using a hash table.
$ ./speller texts/lalaland.txt
MISSPELLED WORDS
[...]
AHHHHHHHHHHHHHHHHHHHHHHHHHHHT
[...]
Shangri
[...]
fianc
[...]
Sebastian's
[...]
WORDS MISSPELLED:
WORDS IN DICTIONARY:
WORDS IN TEXT:
TIME IN load:
TIME IN check:
TIME IN size:
TIME IN unload:
TIME IN TOTAL: