Exemplo n.º 1
0
 public static void main(String[] args) {
   Scanner in = new Scanner(System.in);
   /* Creating object of AVLTree */
   AVLtree T = new AVLtree();
   bstree bst = new bstree();
   int k = 0;
   while (true) {
     k = in.nextInt();
     if (k == -1) break;
     T.root = T.insert(k, T.root);
     bst.addNode(k);
     System.out.println("AVLTree Inorder:");
     T.inorder();
     System.out.println();
     System.out.println("BST Inorder:");
     bst.inorder(bst.root);
     System.out.println();
     System.out.println("AVLTree BFS:");
     T.printBFS(T.root);
     System.out.println();
     System.out.println("bstree BFS:");
     bst.breadthFirst(bst.root);
     System.out.println();
     System.out.println(T.root.data);
   }
 }