Universidad Autónoma Metropolitana Carlos Alberto Orta Cruz matricula 208365480 Estructura de Datos 4600009 Grupo DC02T Árbol Binario #include #include #include struct arbol { int dato; struct arbol *izq; struct arbol *der; }*raiz; enum{ FALSO=0, VERDADERO }; void inicializar( void ); int vacio( struct arbol *hoja ); struct arbol *insertar( struct arbol *raiz, struct arbol *hoja, int num ); int busqueda( struct arbol *hoja, int num ); struct arbol *borrarx( struct arbol *hoja, int num ); void menu_busquedas( void ); void menu_podar( void ); void preorden( struct arbol *hoja ); void inorden( struct arbol *hoja ); void posorden( struct arbol *hoja ); int main() { int opc; int val; inicializar(); while( opc !='S' ) { clrscr(); gotoxy(1,1);printf( "\n MENU ARBOL BINARIO"); gotoxy(1,2);printf( "\n1. Insertar." ); gotoxy(1,3);printf( "\n2. Eliminar " ); gotoxy(1,4);printf( "\n3. Buscar." ); gotoxy(20,5); inorden( raiz );
gotoxy(20,6); preorden( raiz ); gotoxy(20,7); posorden( raiz ); gotoxy(1,5);printf( "\n4. Salir" ); gotoxy(1,7);printf( "\n opcion: " ); scanf("%d",&opc); switch( opc ) { case 1: printf( "\n\nNumero: " ); scanf( "%i", &val ); if( busqueda( raiz, val ) ) { printf( "\n\nEste numero ya ha sido insertado." ); getch(); break; } raiz= insertar( raiz, raiz, val ); break; case 2: //eliminar if( vacio( raiz ) ) { printf( "\n\nEl Arbol Aun esta Vacio." ); getch(); break; } menu_podar(); break; ...
Leer documento completo
Regístrate para leer el documento completo.