subject

This will be your first foray into an actual ADT implementation. It is not a toy program, but the
real deal. You'll take the binary search tree implemented in the modules (and supplied in your
downloaded header file libraries) and modify it to use lazy deletion rather than the explicit
"hard deletion."
If you have carefully studied and experimented with the binary search tree template class, this
assignment should be "just right". It is not as difficult as doing an ADT from scratch, which might
require more than a week. Nonetheless, in the few methods that you must retool, you'll find just
enough of a challenge to feel like you are really cracking the problem. The changes and
debugging you will be doing are typical of ADT design.
Copy the file FHsearch_tree. h and name the copy FHlazySearchTree. h. Work on the latter file
for this assignment. Keep the names of the classes the
same: FHs_treeNode and FHsearch_tree. This way a client that works for the old "non-lazy"
trees will still work for the new ones without modification.
1. Add a bool deleted member to FHs_treeNode. Adjust this class to accommodate this
member.
2. Add a new int mSizeHard member to the FHsearch_tree class which tracks the number
of "hard" nodes in it, i. e., both deleted and undeleted. Meanwhile, mSize is still there
and will only reflect the number of undeleted nodes. Normally, the client will not need to
know about mSizeHard, but we want it for debugging purposes. Give it an
accessor, sizeHard(), so the client can test the class by displaying both the soft size (the
number the client normally wants) and the hard size.
3. Revise remove() (the private/recursive version) to implement lazy deletion.
4. Adjust insert() and any other methods that might need revision to work with this new
deletion technique. (The only exceptions to this is the height-related members and
methods which are only there for the derived class AVL tree. You can ignore any heightrelated code you find in the .h file.) (Also, note that when you insert() a new node you will
be inserting as if the deleted nodes were still there. For example, assume a sub tree, root
= 4, lchild = 1, rchild = 6. 4 is deleted. Insert 5. You could approach this by replacing "4"
with "5", but that's not what you should do. You should insert the 5 as if the 4 were still
there and make it a lchild of 6.)
5. Add a public/private pair, void collectGarbage() (the private method is the recursive
counterpart of the public one). This allows the client to truly remove all deleted (stale)
nodes. Don't do this by creating a new tree and inserting data into it, but by traversing
the tree and doing a hard remove on each deleted node. This will require that you have
a private removeHard() utility that works very much like our old remove() method.
6. findMin() and findMax() should return the min or max of the undeleted nodes. In other
words, they should not consider deleted nodes. This means you'll need an additional
function, findMinHard(), which finds the actual min, even if deleted, for use by
removeHard().
7. Test your code thoroughly. Documentation? No need for documentation in functions that you just modified. Just write
function comments for the functions that you wrote completely: the two garbage collection
functions, sizeHard(), findMinHard(), and remove_hard().

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:00
6. the is particularly susceptible to the effects of alcohol because it receives a large portion of total blood flow and has a high concentration of neurons. a. heart b. pancreas c. brain d. liver
Answers: 2
question
Computers and Technology, 22.06.2019 10:20
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
question
Computers and Technology, 22.06.2019 18:00
Which of the following physical laws can make the flow of water seem more realistic? a. motion b. gravity c. fluid dynamics d. thermodynamics
Answers: 2
question
Computers and Technology, 23.06.2019 01:00
Complete the sentence about a presentation delivery method
Answers: 2
You know the right answer?
This will be your first foray into an actual ADT implementation. It is not a toy program, but the
Questions
question
Mathematics, 16.10.2020 22:01
question
Mathematics, 16.10.2020 22:01
question
Mathematics, 16.10.2020 22:01
question
Mathematics, 16.10.2020 22:01
question
Geography, 16.10.2020 22:01
question
Mathematics, 16.10.2020 22:01
Questions on the website: 13722363