-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAVLTreeInterface.java
More file actions
executable file
·46 lines (31 loc) · 1.68 KB
/
AVLTreeInterface.java
File metadata and controls
executable file
·46 lines (31 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//package calculatenr;
import java.util.Iterator;
public interface AVLTreeInterface<K,V>{
// true if node at position p is external, false otherwise
public boolean external(Position<K,V> p);
// returns the postition of the left child of p
public Position<K,V> left(Position<K,V> p);
// returns the postition of the right child of p
public Position<K,V> right(Position<K,V> p);
// Returns the dictionary entry associated with the input key. If key is not in the tree returns null
public DictEntry<K,V> find(K key);
// Delete entry with key K. Throws exception if key is not present in the tree
public DictEntry<K,V> remove(K key) throws AVLTreeException;
// Finds the entry with the input key, and changes the value of this entry to valueNew
// If the entry with input key is not in the tree, throws AVLtreeException
public void modifyValue(K key, V valueNew ) throws AVLTreeException;
// inserts new entry in the dictionary. If the entry with the input key already exists in the
// tree, throws AVLTreeException
public void insertNew(K key, V value) throws AVLTreeException;
// Returns true if no entries in the tree, false otherwise
public boolean isEmpty();
// Returns the root of the tree.
public Position<K,V> giveRoot();
// returns the height of the tree
public int treeHeight();
// returns an iterator over all entries in the dictionary
// "inOrder" traversal is performed
public Iterator<DictEntry<K,V>> inOrder();
// returns the number of entries in the tree
public int size();
}