
Concept explainers
Consider a binary search tree implemented in Java with a node inner class as shown. The tree is implemented as a full binary tree where internal nodes store keys and external nodes are dummy leaves containing null in their key and value fields. Several standard methods have been implemented as discussed in class, but are not shown below. Complete the implementation of the method getMaximum() which must return the value of the largest key in the binary search tree, by filling in the blanks.
public class BinarySearchTree <K extends Comparable<K>,V> {
private static class Node<K,V> {
private V value;
private K key;
private Node<K,V> left;
private Node<K,V> right;
private Node<K,V> parent;
private Node(K key, V value) {
this.value = value;
this.key = key;
left = null;
right = null;
parent= null;
}
}
private Node<K,V> root = new Node<K,V>(null,null);
// initializes an empty tree with dummy leaf
// Assume we have implemented methods: V search(K key); insert(K key, V value);
// V delete(K key); boolean isExternal(Node<K,V> node); int size(); etc.
public K getMaximum() {
if (isExternal(root)) return null;
Node<K,V> current = root;
while (________________________ ) {
_________________________ ;
}
return __________________ ;
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





