Question: c++ Goal Create a Dictionary class and a program that tests it. Details A Dictionary is a basic container class that supports the five basic

Goal Create a Dictionary class and a program that tests it. Details A Dictionary is a basic container class that supports the five basic operations - createdestroy. clear, isEmpty and size -- as well as the following four operations: void insert(KeyType k, ValueType v) Insert the key-value pair (k, v) into the dictionary. If k already exists, then throw a domain_error exception. void remove (KeyType k) Remove the key k and its corresponding value. If k is not in the dictionary, then throw a domain_error exception. ValueType search(KeyType k) Search for the key k. If found, return the corresponding value. If not found, throw a domain_error exception. void update (KeyType k, ValueType v) Search for the key k. If found, change its corresponding value to v. If not found, throw a domain_error exception. In addition, a Dictionary can support the following operations: void forceUpdate (KeyType k,ValueType v) Same as update(), but if the key is not found, the pair is inserted into the dictionary. bool getFirstKey(KeyType &k) Sets k to the first key in the dictionary. Returns false if the dictionary is empty. bool getNextKey (Key Type &k) Stores the next key found in k Returns true if a key is found, false if no more keys exist. The intent of getFirstKey() and getNextKey() is to loop through all keys currently in the dictionary. Here's some example code: 1 bool haveKey = d.getFirstKey(); 2 while haveKey){ // do something with k, like d. search(k) to get the value haveKey = d.getNextKey(k); 5} For our purposes, the dictionary must be able to hold at least 100 key-value pairs. 3 4 Implementing the dictionary You can use any of the three main techniques - Unsorted Dictionary. Sorted Dictionary or Hashed Dictionary. My preference is for hashed, as that should give the best performance. Use either the hashpjw() or my weighted hash function. For this project, the KeyType must be string and the ValueType must be Fraction. Testing the dictionary Write a short program that creates a Dictionary. Then, use a loop to present a menu to the user. The menu should provide options for all Dictionary operations -- insert, remove, search, update. IsEmpty, size, clear. If you chose to implement the additional operations, present those in the menu as well (the getFirstKey and getNextKey should be one option that does the loop). Perform the chosen action and continue in the loop until the user chooses to quit What to turn in Turn in your source code and Makefile
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
