Question: A map or a dictionary, also known as an associative array, is a data structure in which key - value pairs can be inserted; then

A map or a dictionary, also known as an associative array, is a data structure in which key-value pairs can be inserted; then you can access any value by supplying the key. It's like an array in which you can access elements with perhaps a string index (key) or any other type of index. We assume that the keys are unique so if you insert a key-value pair and the key already exists then you just overwrite the value.
Write a C++ template class to represent a map. To avoid name collisions you can call your class 'Dict'. Use a BST to implement your class. You will need to create a C++ template class for the BST. You can modify the code that we presented in class for the BST. Test your map/dictionary with the following main function:
```
#include
#include
#include "Dict.hpp"
using namespace std;
int main()
{
Dict phone_directory;
phone_directory.add("Tom",4236);
phone_directory.add("Pat",4237);
cout "Tom " "Ext.: " phone_directory["Tom"] endl;
cout "Pat " "Ext.: " phone_directory["Pat"] endl;
Dict id_numbers;
id_numbers.add(1023\overline{0}4, "Tom");
id_numbers.add(102305, "Pat");
cout id_numbers [102304] endl;
cout id_numbers[102305] endl;
return 0;
}
``` In this case your program should output:
Tom Ext.: 4236
Pat Ext.: 4237
Tom
Pat
Submit all source files needed to build and run your program to Gradescope.
A map or a dictionary, also known as an

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!