package DDtester;
//Comment out one of the following two for a given run
//import ddAsBST.*;
import ddAsAVL.*;
import java.util.Random;

public class DDtester {
	public static void main(String[] args) {// Argument: number of inserts to be
											// performed
		int n = (args.length == 0) ? 1000 : Integer.parseInt(args[0]);
		// The default value for n is 10
		long time1 = System.nanoTime();
		DynamicDict dict1 = new DynamicDict();
		
		// *******For comparing on RANDOM input sequences
		Random r = new Random();
		// An integer argument to Random() ensures that the same sequence is
		// generated each run
		// Perform 2n insertions into the dictionary...
		
		//So ten entries
		/*
		System.out.println("Performing the following number of inserts: "+n);
		
		for (int i = 0; i < n; i++) {
			int k = r.nextInt(2 * n);
			System.out.println("Inserting "+k);
			dict1.insert(k, "The Number is " + Integer.toString(k));
		}
		*/
		
		
		//System.out.println("custom run of 3 or 4 inserts");
		//testing LL
		//dict1.insert(16, "The number is 16");
		//dict1.insert(13, "The number is 13");
		//dict1.insert(1, "The number is 1");
		
		//testing RR
		//dict1.insert(1, "The number is 1");
		//dict1.insert(13, "The number is 13");
		//dict1.insert(16, "The number is 16");
		
		//testing LR
		//dict1.insert(7, "The number is 7");
		//dict1.insert(3, "The number is 3");
		//dict1.insert(4, "The number is 4");
		//dict1.insert(5, "The number is 5");
		
		
		//System.out.println("After n insertions, we have this many nodes: "+dict1.count());
		//System.out.println("----------------Now Deleting--------------------");
		
		// ... and then n removes
		/*
		for (int i = 0; i < n / 2; i++){
			int whatToRemove = r.nextInt(2 * n);
			System.out.println("Trying to remove: "+whatToRemove);
			dict1.remove(whatToRemove);
		}
		*/
		
		
		
		
		// *******For comparing on INCREASING input sequences
		/*
		for (int i=0; i<n; i++) dict1.insert(i, "The Number is " +
		 Integer.toString(i));
		 for (int i=0; i<n/2; i++) dict1.remove(r.nextInt(n));
		*/
		 
		 
		 //
		// *******For comparing on DECREASING input sequences
		///* 
		for (int i=0; i<n; i++) dict1.insert(n-i, "The Number is " +
		 Integer.toString(n-i));
		 for (int i=0; i<n/2; i++) dict1.remove(r.nextInt(n));
		// */
		
		
		
		System.out.println("Run Time: "+(System.nanoTime() - time1) / 1000000);
		// DynamicDict.height() and DynamicDict.count() are NOT dynamic
		// dictionary methods:
		// theyÕre here to help us in our experiments
		System.out.println("Tree count is " + dict1.count());
		System.out.println("Tree height is " + dict1.height());
	
	}
}