BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C++代写 | CS515 Assignment 7

C++代写 | CS515 Assignment 7

这个作业是用C++完成ADT抽象数据结构和二叉搜索树
CS515
Assignment 7
• You must implement the map erase() method following the algorithm discussed in class. In
particular, the node to be deleted is swapped with its in-order successor, and then is deleted.
• There will be two ways to insert a key-data pair into a Map:
o Approach 1: Use the insert() method. The method will insert the key/value pair into the Map if
the key doesn’t exist, and return true. If the key already exists, the method will return false.
o Approach 2: Use the overloaded operator[]. The operator[] is overloaded so we can search
and access the data in a map similar as in a built-in array. Consider a map m contains entries
that map string to string, and suppose m contains an entry associated with key “a”, then
string s = m[“a”];
will access the string indexed by the key “a” and assign its value to s.
m[“a”] = “new string value”;
will update the string that is associated with “a” to a new string “new string value”
If, however, m does not contain any entries associated with key “a”, then
m[“a”];
will insert into map m a new entry whose key is “a”, and its data (an empty string) is returned
so we can update it with an assignment.
Again, suppose m does not contain an entry associated with key “a”, then
m[“a”] = “new string value”;
will insert a new entry made of the key “a” and the value “new string value”.
Make sure to test your program thoroughly, considering all corner cases you can think of (in
particular, try to find all basis paths through each method). The provided sample test is very
inadequate and is there mostly to show you how the tree grows with each new insert, for initial
debugging. You should use the tests that you wrote for 5P as a starting point for thorough tests here.
You need to keep in mind this BST-based Map implementation is not guaranteed to be O(logN) since a
BST is not guaranteed to be balanced.
2

bestdaixie

评论已关闭。