binary search tree java

profilejrjamespuax
BST.java

import java.util.ArrayList; import java.util.List; import java.util.Stack; /** * * @author Juan Dominguez * @author Qiyue Wang * * @param <K> The type of the keys of this BST. They need to be comparable by nature of the BST * "K extends Comparable" means that BST will only compile with classes that implement Comparable * interface. This is because our BST sorts entries by key. Therefore keys must be comparable. * @param <V> The type of the values of this BST. */ public class BST<K extends Comparable<? super K>, V> implements DefaultMap<K, V> { /* * TODO: Add instance variables * You may add any instance variables you need, but * you may NOT use any class that implements java.util.SortedMap * or any other implementation of a binary search tree */ @Override public boolean put(K key, V value) throws IllegalArgumentException { // TODO Auto-generated method stub return false; } @Override public boolean replace(K key, V newValue) throws IllegalArgumentException { // TODO Auto-generated method stub return false; } @Override public boolean remove(K key) throws IllegalArgumentException { // TODO Auto-generated method stub return false; } @Override public void set(K key, V value) throws IllegalArgumentException { // TODO Auto-generated method stub } @Override public V get(K key) throws IllegalArgumentException { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } @Override public boolean isEmpty() { // TODO Auto-generated method stub return false; } @Override public boolean containsKey(K key) throws IllegalArgumentException { // TODO Auto-generated method stub return false; } // Keys must be in ascending sorted order // You CANNOT use Collections.sort() or any other sorting implementations // You must do inorder traversal of the tree @Override public List<K> keys() { // TODO Auto-generated method stub return null; } private static class Node<K extends Comparable<? super K>, V> implements DefaultMap.Entry<K, V> { /* * TODO: Add instance variables */ @Override public K getKey() { // TODO Auto-generated method stub return null; } @Override public V getValue() { // TODO Auto-generated method stub return null; } @Override public void setValue(V value) { // TODO Auto-generated method stub } } }