Creacion de Arboles en C++ (Estructura de Datos)

Páginas: 2 (449 palabras) Publicado: 17 de junio de 2013
#include
#include
#include
#include

struct arbol
{
int info;
struct arbol *left;
struct arbol *right;
};

typedef struct arbol nodetree;
typedef nodetree *arbolptr;void insertar(arbolptr*L, int b);
void imprimir(arbolptr L);
void preorden(arbolptr L);
void entreorden(arbolptr L);
void posorden(arbolptr L);
void instrucciones();

main()
{arbolptr L=NULL;
int inf, opcion;
instrucciones(),
scanf("%d",&opcion);
while(opcion!=6)
{
switch(opcion)
{
case 1:{
coutclave == elem){
aux = *a;
if ((*a)->izq == NULL) *a = (*a)->der;
else if ((*a)->der == NULL) *a = (*a)->izq;
else sustituir(&(*a)->izq, &aux); /* se sustituye por la mayor de las menores */free(aux);
}
}

void sustituir(tarbol **a, tarbol **aux)
{
if ((*a)->der != NULL) sustituir(&(*a)->der, aux);
else {
(*aux)->clave = (*a)->clave;
*aux = *a;
*a =(*a)->izq;
}
}

-----------------------------------------------------------------------------
#include
#include
#include
struct arbol{
int info;
struct arbol *left;
struct arbol *right;
};typedef struct arbol nodetree;
typedef nodetree *arbolptr;
void insertar(arbolptr*L, int b);
void imprimir(arbolptr L);
void preorden(arbolptr L);
void entreorden(arbolptr L);
voidposorden(arbolptr L);
void instrucciones();
main()
{
arbolptr L=NULL;
int inf, opcion;
instrucciones(),
(" \n Seleciona la opcion: \n");
scanf("%d",&opcion);
while(opcion!=5){
switch(opcion)
{
case 1:{printf("\n Introduzca el elemento:");
scanf("%d",&inf);
insertar(&L,inf);
imprimir(L);
instrucciones();
break;
}
case 2: {
printf("Pre-orden");
preorden(L);
break;
}
case 3: {printf("Entre-orden");
entreorden(L);
break;
}
case 4: {
printf("Pos-orden");
posorden(L);
break;
}
case 5: {
printf("Fin del programa");
break;
}
default:
printf("Operacion invalida");...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Estructuras de datos en C/C++
  • Arboles (estructura de datos)
  • Arboles estructura de datos
  • Arboles generales en estructuras de datos
  • Arboles (Estructura de Datos)
  • Arboles (estructura de datos)
  • Arboles estructura y base de datos
  • arboles

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS