Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Code must be written as stated in the Instructions. Project 3 Binary Search Trees with Lazy Deletion The task of this project is to

image text in transcribedimage text in transcribedimage text in transcribed

Java Code must be written as stated in the Instructions.

Project 3 Binary Search Trees with Lazy Deletion The task of this project is to implement in Java a binary search tree with lazy deletion. The BST class should contain a nested tree node class that is used to implement the BST Specification The project must implement the following specification exactly, which includes identifier names, method signatures, the presence or absence of exceptional behavior, etc. Anything not clearly indicated by the UML class diagram (such as the access level of TreeNode fields, note the TreeNode class itself is private nested inside LazyBinarySearchTree class) or explicitly stated in the natural language description is left up to your discretion. You may also add helper methods and additional fields as you see fit - in fact, you may find it necessary to do so! Structure LazyBinarySearchTree root: TreeNode TreeNode +insert(key: int): boolean throws lllegalArgumentException) +delete(key: int): boolean (throws IllegalArgumentException +findMin0: int +findMax0: int +contains(key: int): boolean [throws IllegalArgumentException) +toString0: String +height0: int +size0: int key: int leftChild: TreeNode rightChild: TreeNode deleted: boolean Note that the (+) relation in UML denotes nesting of scope, and not just composition of use Behavior insert should insert a new element to a leaf node. The valid set of keys is all integers in the range [1,99]. If the new element would be a duplicate of a non-deleted element already in the tree, then insert should do nothing. However, if the new element is not a duplicate of a non- deleted element, but is a duplicate of a deleted element, then insert should "undelete" the deleted element in-place rather than physically inserting a new copy of the element. The return value of insert should indicate whether insert logically (as opposed to physically) inserted a new element. delete should not physically remove an element from the tree. Rather, it should mark the specified element as logically deleted. If the specified element is not in the tree or is already marked as deleted, then delete should do nothing. The return value of delete should indicate whether delete logically deleted an element

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago