Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ejercicio1 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- menu();
- }
- public static void menu() {
- BinaryTree<Character> a1 = new BinaryTree<Character>('B', new BinaryTree<Character>('A'), new BinaryTree<Character>('C'));
- BinaryTree<Character> a2 = new BinaryTree<Character>('G', new BinaryTree<Character>('F'), null);
- BinaryTree<Character> a3 = new BinaryTree<Character>('E', null, a2);
- BinaryTree<Character> a = new BinaryTree<Character>('D',a1,a3);
- int opcion;
- do {
- System.out.println("Arbol:\n " + a.toString());
- System.out.println("1 - Mostrar datos del arbol");
- System.out.println("2 - Mostar Recorrido del arbol en ORDEN DESCENDENTE");
- opcion = Helper.getPositiveInt("Ingrese una opcion");
- switch(opcion) {
- case 1:
- datosDeA(a);
- Helper.espera();
- break;
- case 2:
- recorridoDeA(a);
- Helper.espera();
- break;
- case 3:
- break;
- default:
- System.out.println("Erro: opcion no valida");
- }
- }while(opcion != 3);
- System.out.println("Gracias :D");
- }
- public static void datosDeA(BinaryTree<Character> arbol) {
- System.out.println("DATOS DEL ARBOL");
- System.out.println("****************************************");
- System.out.println("El numero total de nodos es: " + arbol.NodeCount());
- System.out.println("El numero de hojas es: " + arbol.LeafCount());
- System.out.println("El numero de nodos internos es: " + arbol.InternalCount());
- System.out.println("El nivel maximo del arbol es: " + arbol.MaxLevel());
- System.out.println("La altura del arbol es: " + arbol.Height());
- System.out.println("****************************************");
- }
- public static void recorridoDeA(BinaryTree<Character> arbol) {
- System.out.println("El orden descendente es:");
- arbol.DescendingOrder();
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment