Skip to content
Snippets Groups Projects
Commit 2c8b9d01 authored by Adam Blank's avatar Adam Blank
Browse files

Update BinarySearchTree.java

parent 18be7b6f
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ public class BinarySearchTree<K extends Comparable<K>, V>
}
}
private BSTNode find(K key, V value) {
protected BSTNode find(K key, V value) {
BSTNode prev = null;
BSTNode current = this.root;
......@@ -89,6 +89,9 @@ public class BinarySearchTree<K extends Comparable<K>, V>
@Override
public V find(K key) {
if (key == null) {
throw new IllegalArgumentException();
}
BSTNode result = find(key, null);
if (result == null) {
return null;
......@@ -98,6 +101,9 @@ public class BinarySearchTree<K extends Comparable<K>, V>
@Override
public V insert(K key, V value) {
if (key == null || value == null) {
throw new IllegalArgumentException();
}
BSTNode current = find(key, value);
V oldValue = current.value;
current.value = value;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment