Question: This method is part of the Binary Search Tree implementation. Question: Replace the put(K key, V value) method with a recursive method i.e. one that

This method is part of the Binary Search Tree implementation. Question: Replace the put(K key, V value) method with a recursive method  i.e. one that doesnt use a loop. public void put(K key, V value) { if (root == null) { TreeNode node = new TreeNode(key, value); this.root = node; } else { TreeNode current = root; while (current != null) { int c = key.compareTo(current.key); // key == current.key if (c == 0) { current.value = value; return; } // key < current.key else if (c < 0) { if (current.left != null) { current = current.left; } else { TreeNode node = new TreeNode(key, value); current.left = node; } } //c > 0, i.e. key > current.key else { if (current.right != null) { current = current.right; } else { TreeNode node = new TreeNode(key, value); current.right = node; } } } } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!