#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct no
{
char chave[15];
struct noesq;
struct nodir;
struct no*pai;
};
typedef struct no No;
void inserir(Nox)
{
printf("%s",x->chave);
Noy=NULL;
while(x!=NULL)
{
y=x;
No*z= NULL;
if(strcmp(x->chave,y->chave)==0)
printf("%s",x->chave);
if(strcmp(y->chave,z->chave)>0)
printf("%s",y->chave);
if(strcmp(y->chave,z->chave)<0)
printf("%s",z->chave);
}
}
int main()
{
return 0;
}
Qual o problema? Seria o looping infinito na função void inserir(No x) ?
Queria saber ser estou fazendo correto
Já executou o código?
Isso ira gerar um looping infinito while(x!=NULL)
Já executei , não gera loop infinito não , mas você manja de arvores ?
Ainda lembro alguma coisa do que vi na faculdade.
1 curtida
Hum tenho que fazer baseado neste pseudocodigo
TREE_INSERT( T, z )
1 y ← NULL
2 x ← raiz( T )
3 enquanto x ≠ NULL, faça:
4 y ← x
5 se chave( z ) < chave ( x ), então:
6 x ← esquerda( x )
7 senão: x ← direita ( x )
8 pai( z ) ← y
9 se y = NULL, então:
10 raiz ( T ) ← z
11 senão: se chave ( z ) < chave ( y ), então:
12 esquerda( y ) ← z
13 senão: direita( y ) ← z