import java.util.*; /* This is a class for testing the behavior of the AVL class, for Assignment 2, CS 146, Spring 2003. All of the methods are static, so the default constructor is acceptable. */ public class A2 { /** Prints the elements of a List on the same line, separated by single spaces. @param the list */ public static void traverseList(List l) { Iterator lit = l.iterator(); while (lit.hasNext()) System.out.print(lit.next() + " "); System.out.println(); } /** Constructs a randomly created String of length 3 consisting of random lower-case letters, except that the 2nd letter is 'a'. @param r a Random object used to create the characters @return the randomly created String. */ public static String randomString(Random r) { StringBuffer sb = new StringBuffer(3); sb.append((char) ('a'+r.nextInt(26))); sb.append('a'); sb.append((char) ('a'+r.nextInt(26))); return new String(sb); } /** Tests the AVL class @param args is ignored. */ public static void main(String[] args) { Random r = new Random(2); AVL a = new AVL(); BinarySearchTree b = new BinarySearchTree(); AVL a2 = new AVL(b); List l = b.traverse(); System.out.println("the size of B is " + l.size()); System.out.println("the height of B is " + b.height()); System.out.println(); System.out.println("the size of A is " + a.size()); System.out.println("the height of A is " + a.height()); System.out.println(); System.out.println("the size of A2 is " + a2.size()); System.out.println("the height of A2 is " + a2.height()); System.out.println(); System.out.println(); int key=2; int factor = 7; int n=17; for (int i=1; i