Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/03/2009, 16:19
JDHCH
 
Fecha de Ingreso: marzo-2009
Mensajes: 2
Antigüedad: 15 años, 1 mes
Puntos: 0
Pregunta que esta mal en este codigo de arbol binario

hola a la comunidad del foro saveb de k tengo un problema con un arbol binariot que tiene que ver con los ordenes k utiliza el preOrden el inOrden y postOrden de busqueda el cual no he podido solucionar ya tengo un error k me dice

cannont convert' void*' to 'treeNode*'


a no ser k sea k el programe k use este ekivocado tambien seria de gran ayuda si me dijieran en k lenguaje seriarecomendable usar este programa



eso con el programa k uso el cual es el
turbo c++ espero y me puedan ayudar nos vemos y gracias

#include <stdio.h>
#include<stdlib.h>
#include<time.h>

struct treeNode{
struct treeNode *leftPtr;
int data;
struct treeNode *rightPtr;
};

typedef struct treeNode TREENODE;
typedef TREENODE * TREENODEPTR;

void insertNode(TREENODEPTR*, int);
void inOrder(TREENODEPTR);
void preOrder(TREENODEPTR);
void postOrder(TREENODEPTR);

main()
{
int i, item;
TREENODEPTR rootPtr= NULL;

srand(time(NULL));


for(i=1; i<=10; i++){
item= rand()%15;
printf("%3d", item);
insertNode(&rootPtr,item);
}

printf("\n\nel proceso de preOrder es:\n");
preOrder(rootPtr);

printf("\n\nel proceso inOrder es:\n");
inOrder(rootPtr);

printf("\n\nThe postOrder es:\n");
postOrder(rootPtr);

return 0;

}

void insertNode(TREENODEPTR *treePtr, int value)
{
if(*treePtr==NULL){
/* *treePtr is NULL */
treePtr=malloc(sizeof(TREENODE)); --------- aki esta el error segun el compilador
if(*treePtr !=NULL){
(*treePtr)->data=value;
(*treePtr)->leftPtr= NULL;
(*treePtr)->rightPtr=NULL;
}
else
printf("&3d no insertado. No hay memoria disponible.\n",value);

}
else
if(value < (*treePtr)->data)
insertNode(&((*treePtr)->leftPtr), value);
else
if(value >(*treePtr)->data)
insertNode(&((*treePtr)->rightPtr), value);
else
printf("dup");
}

void inOrder(TREENODEPTR treePtr)
{
if(treePtr != NULL){
inOrder(treePtr->leftPtr);
printf("%3d", treePtr->data);
inOrder(treePtr->rightPtr);
}
}

void preOrder(TREENODEPTR treePtr)
{
if(treePtr !=NULL) {
printf("%3d", treePtr->data);
preOrder(treePtr->leftPtr);
preOrder(treePtr->rightPtr);
}
}

void postOrder(TREENODEPTR treePtr)
{
if(treePtr != NULL){
postOrder(treePtr->leftPtr);
postOrder(treePtr->rightPtr);
printf("%3d", treePtr->data);
}
}