Use Linear, Binary, and Hash (chaining) search algorithms to determine the runtime of each search algorithm with different sizes of N.
-
You will see that there is commented code in the
main.cpp
file. If you want to run all 3 searches for the sameN
, uncomment all the code and compile. Otherwise, it's best to run one search per session to get faster results. -
Please update the line
int arraySize = MAX_SIZE2XX;
, with a newMAX_SIZE2XX
. This will be the size of N. It is recommended that you use larger N for Binary and Hash searches. Linear searches will take a really long time to finish with large N. -
Compile
main.cpp
and run the executable.
Creating hash table of size 67108864.
Generating hash table of size 67108864
Generating random strings...
Finished generating random strings...
Populating the hash table with random strings...
The hash table is ready for searching...
Generating test data set...
Finished generating test data set...
Generated test data set of 67108864 elements.
Executing hash search ...
Elapsed time: 0 hour(s) 1 minute(s) 4 seconds 64774 milliseconds.
Linear is in Green. Binary is in Red. Hash is in Orange.
Log your N and Time, and create a graph of Time vs N. I used Google Spreadsheets for this.