Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

void insert(String key) { root = insertRec(root, key); } /* A recursive function to insert a new key in BST */ TreeNode insertRec(TreeNode root, String

void insert(String key) {

root = insertRec(root, key);

}

/* A recursive function to insert a new key in BST */

TreeNode insertRec(TreeNode root, String key) {

/* If the tree is empty, return a new TreeNode */

if (root == null) {

root = new TreeNode(key);

return root;

}

/* Otherwise, recur down the tree */

if (key.compareToIgnoreCase(root.key) < 0)

root.leftChild = insertRec(root.leftChild, key);

else if (key.compareToIgnoreCase(root.key) > 0)

root.rightChild = insertRec(root.rightChild, key);

/* return the (unchanged) TreeNode pointer */

return root;

}

I have made this insert method for Binary Search Tree.

Now I need to make methods for delete and retrieve an item in the Binary Search Tree.

Can I get a java code for this? Thanks

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago