import java.util.Random; /* * Copyright (C) 2021 Gabriel Venberg * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * * @author Gabriel Venberg */ public class Client { public static void main(String args[]){ //set up stuff needed for test. final int BSTSize = 1000000; long startTime; long endTime; String[][] data = new String[7][2]; //acending order test BinarySearchTree testTree = new BinarySearchTree(); startTime=System.nanoTime(); for(int i=0; i=0; i--){ testTree.insert(i); } data[1][1] = String.format("%,d", testTree.hight()); endTime=System.nanoTime(); data[1][0]=String.format("%,d", endTime-startTime); testTree.preorderTraversal(testTree.root()); System.out.println(); testTree.postorderTraversal(testTree.root()); System.out.println(); testTree.inorderTraversal(testTree.root()); System.out.println(); //generate arrray containing numbers 0 through 999,999, for 1 million unique numbers. int[] uniqueNumbers = new int[BSTSize]; for(int i=0; i