/* * === FUNCTION ====================================================================== * Name: Imprimir * Description: Imprime el arbol en recorrido postorden * ===================================================================================== */ void postOrden(Arbol a){ if (a != NULL) { preOrden(a->izq); preOrden(a->der); printf("%d\n",a->Elem); } }
void Arbol::preOrden(Arbol *raiz) { if(!raiz) return; insertar(valor,raiz); preOrden(raiz->hijoIzquierdo); preOrden(raiz->hijoDerecho); }
void preOrden(AVL a ) { if(a) { printf(" %d ", a -> info ); preOrden( a -> izq ); preOrden( a -> der ); } }
void operaAB( AVL *a ) { int opc, dato; char res; *a = NULL; do { opc = imprimeMenu(); switch( opc ) { case 1: system( "cls" ); puts( "\n Arbol creado .....\n\n " ); iniAVL( a ); system( "pause" ); break; case 2: procesoDeInsercion( a ); break; case 3: system("cls"); puts( "\n\n" ); preOrden(*a); puts( "\n\n" ); system("pause"); break; case 4: do { system("cls"); if( buscaDatoAVL( *a ,dato = leer( "\n Digite el numero a buscar : " ) ) ) { printf("\n El dato %d existe en el arbol\n\n ", dato ); res = -1 ; } else { printf("\n El numero %d no existe\n\n ", dato ); printf(" Otra busqueda ? ( S / N ) : " ); fflush(stdin); scanf("%c", &res ); } }while( res == 's' || res == 'S' ); system("pause" ); break; case 5: moduloDeEliminacion( a );break; } }while( opc > 0 && opc < 6 ); }
/* * === FUNCTION ====================================================================== * Name: Imprimir * Description: Imprime el arbol seleccionando el tipo de recorrido * ===================================================================================== */ void Imprimir (Arbol a, int n){ switch ( n ) { case 0: preOrden(a); break; case 1: postOrden(a); break; case 2: inOrden(a); break; default: break; } /* ----- end switch ----- */ }