Fun Part:
Were going to create crazy names similar to what github and repl.it do when suggesting names for repls or repos. Github suggests things like: musical-journey or cautious-waffle or bug-free-succotash. Whereas repl.it suggests things like: LikelyTatteredGreatwhiteshark or PepperySunnyMaggot or ClearcutLongtermCrocodile or RowdyWorthwhileBird. I'm not sure what thier algorithm is, but I'm sure we can come up with something better (or at least similar).
Data Structures Part:
After we generate about 10000 names, we are going to compare the performance of a Binary Search Tree vs an AVL tree when it comes to finding those named components in each tree.
I think most of us remember what types of words there are:
ad.jec.tive | noun | verb | adverb |
ajaktiv | noun | varb | ad varb |
a word or phrase naming an attribute, added to or grammatically related to a noun to modify or describe it. | a word (other than a pronoun) used to identify any of a class of people, places, or things common noun, or to name a particular one of these proper noun. | a word used to describe an action, state, or occurrence, and forming the main part of the predicate of a sentence, such as hear, become, happen. | qualifies an adjective, verb, or other adverb or a word group, expressing a relation of place, time, circumstance, manner, cause, degree, etc. (e.g., gently, quite, then, there ) |
There are a few more word categories (I think) but we don't really need those to make our crazy words. What we do have are words lists for the above categories + a list of animal names:
Motivation
Binary search tree's are only good when they are balanced. So we are going to compare an AVL implementation of a Binary Search Tree to a regular implementation that is not balanced.
Why Crazy Words?
Because there are a lot of words and we need data to load into both of our data structures in order to compare performance. The word lists only number in the thousands, so we won't be bogging down our computers trying to handle the data, but its enough data to motivate us to be efficient. And crazy words are funny.
Part 1
crazywords.txt
rowdy worthwhile bird
bug free succotash
peppery sunny maggot
cautious waffle
Part 2
BST Comparisons = xxx
AVL Comparisons = xxx
Number of Adjectives = xxx
Number of Adverbs = xxx
Number of Nouns = xxx
Number of Verbs = xxx
1.Read each of the word files into some structure (possibly an array).
2.Build your crazy random words (with no repeats) and save them into tenthousandwords.txt
3.Load all of the word files into your BSTree and AVLtree in this order:
adjectives
adverbs
animals
nouns
animals
verbs
4.Make sure you don't load duplicates into either of your trees!!
5.The adjectives file should start with an M word.
6.Open your tenthousandwords.txt and as you read in each crazy word: look up each word component in the BSTree and AVLtree to count comparisons.
7.Output your results to screen and file.