Google is still hiring! Last time you implement a deque resume container to help Google HR deal with the large amount of resumes, but HR complains that they are tired of searching resumes one by one. They want to have a more convenient container to help them. So this time you are going to use BST to implement a more efficient BSTMap container for them.
In this lab, you are going to implement a Map container based on the BST implementation that you have learned in the lecture. For details of BST, please refer to the lecture notes. The BSTMap you are going to implement is actually a BST in which each node has a key and a value. Keys are sortable data, and values are data tagged with their keys.
Following external links for similar data structures may be useful to you:The descriptions of classes and members in classes are as follows:
Structure Pair
: Data stored in a MapItem.
K key
:V value
:Structure MapItem
: Structure defined in Class BSTMap.
Pair data
:BSTMap left
:BSTMap right
:MapItem(const MapItem&)
:~MapItem()
:MapItem(const K& k, const V& v)
:class BSTMap
:
MapItem* root
:BSTMap()
:~BSTMap()
:BSTMap(const BSTMap& bst)
:const Pair& find_min()
:const Pair find_max()
:is_empty()
:contains(const K& key)
:void remove(const K& key);
:void insert(const K& key, const V& value)
:V& operator[] (const K& key)
(TODO):V operator[](const K& key) const
(TODO)::BSTMap& operator=(const BSTMap& bst)
(TODO):int size()
(TODO):operator<<
(TODO):operator<<
is alreay overloaded for all types of keys and values.
void clear()
(TODO):
bstmap-todo.tpp
.
lab8
, check with the expected output below:Create resume container for position: C++ developer. Applicants of C++ developer: {Amelia:CUHK} , {David:HKU} , {James:HKUST} , {Yang:HKUST} Merge with C developers applications. Applicants of C & C++ developer: {Amelia:CUHK} , {David:HKU} , {James:HKUST} , {Oliver:PolyU} , {Tony:HKUST} , {Wang:CUHK} , {Yang:HKUST} We have 7 candidates. Some candidates fail in the interview The remaining C & C++ developer candidates: {Amelia:CUHK} , {James:HKUST} , {Oliver:PolyU} , {Tony:HKUST} , {Yang:HKUST} We have 5 candidates. Create a backup of applications. Backup applications: {Amelia:CUHK} , {James:HKUST} , {Oliver:PolyU} , {Tony:HKUST} , {Yang:HKUST} HR wants to search candidates' information Oliver is graduated from PolyU Yang is graduated from HKUST Amelia is graduated from CUHK Oh! HR accidentaly delete all the application forms We have 0 candidates. Don't worry, we have a backup. Let's see whether the information is correct. Amelia is still a candidate? [Yes] James is still a candidate? [Yes] Wang is still a candidate? [No] Tony is still a candidate? [Yes] David is still a candidate? [No]
The due date and time will be 10-min after your lab session. You are supposed to upload the following files in an archive to ZINC:
- bstmap-todo.tppYou can submit your codes multiple times by the deadline. Only the last submission will be graded.