previous | start | next

Adapting BST Tree Methods for an AVL Tree

Assume a private Node class is used for an AVL tree class:

public class AVL<Key extends Comparable<Key>, Value>
{
  // AVL members and methods
  ...

     // inner class
     private class Node 
     {
       private Key key;
       private Value val;
       private Node left;
       private Node right;
       private int height; // optional

       private  Node() {}
       private Node(Key k, Value v) {
         key = k;
         val = v;
         height = 0; // optional? Not really
         left = right = null;
       }
     }
}
   


previous | start | next