Advertisement
jtentor

DemoTree1 - DemoTree1.java

Jun 23rd, 2020
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  2. //
  3. public class DemoTree1 {
  4.     public static void main(String[] args) {
  5.         System.out.println("Demo Arbol Binario");
  6.  
  7.  
  8.         BinaryTree<Character> a1 = new BinaryTree<Character>('B', new BinaryTree<Character>('A'), new BinaryTree<Character>('C'));
  9.         BinaryTree<Character> a2 = new BinaryTree<Character>('G', new BinaryTree<Character>('F'), null);
  10.         BinaryTree<Character> a3 = new BinaryTree<Character>('E', null, a2);
  11.         BinaryTree<Character> a = new BinaryTree<Character>('D', a1, a3);
  12.  
  13. //        BinaryTree<Integer> a1 = new BinaryTree<Integer>(33, new BinaryTree<Integer>(56), new BinaryTree<Integer>(6));
  14. //        BinaryTree<Integer> a2 = new BinaryTree<Integer>(17, new BinaryTree<Integer>(7), null);
  15. //        BinaryTree<Integer> a3 = new BinaryTree<Integer>(29, null, a2);
  16. //        BinaryTree<Integer> a = new BinaryTree<Integer>(8, a1, a3);
  17.  
  18.         System.out.printf("Arbol       %s", a.toString());
  19.         System.out.println();
  20.  
  21.         System.out.print("Pre Orden   ");
  22.         a.PreOrder();
  23.         System.out.println();
  24.         System.out.print("En Orden    ");
  25.         a.InOrder();
  26.         System.out.println();
  27.         System.out.print("Post Orden  ");
  28.         a.PostOrder();
  29.         System.out.println();
  30.         System.out.print("Descendente ");
  31.         a.DescendingOrder();
  32.         System.out.println();
  33.  
  34.         System.out.printf("Cantidad de Nodos %s\n", a.NodeCount());
  35.         System.out.printf("Cantidad de Hojas %s\n", a.LeafCount());
  36.         System.out.printf("Nodos Internos    %s\n", a.InternalCount());
  37.         System.out.printf("Máximo Nivel      %s\n", a.MaxLevel());
  38.         System.out.printf("Altura            %s\n", a.Height());
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement