Michael M.

asked • 03/28/22

Pseudo code Binary Search Tree

Suppose T is the root node of a Binary Search Tree. Tree nodes will be implemented with the usual BST attributes, and an additional attribute called x.deleted is included, which can be set to True or False. Using this new attribute, describe how to delete nodes from the BST T. Provide the pseudo-code for this new algorithm, which is called LazyDelete(T,z). Next, explain how to update the TreeSearch(T,z) algorithm and the TreeInsert(T,z) so that it works with this new lazy binary search tree. You may assume that no duplicates are in the data set at any one time. However, it is possible that we insert a key 5, then delete a 5, and then re-insert a 5. Your algorithms should work in this scenario. What are the downfalls of this new lazy approach? 

Reference pseudocode for TreeSearch and TreeInsert found here.. https://en.wikipedia.org/wiki/Binary_search_tree


2 Answers By Expert Tutors

By:

Michael F. answered • 03/28/22

Tutor
4.8 (44)

30 years college professor of undergraduate math and computer science

Donald W. answered • 03/28/22

Tutor
5.0 (214)

Senior Software Engineer with over 25 years of industry experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.