I have the following code that compiles perfect, but when executing and printing the tree, it is empty.
void arbol::ArbolBusqI(string x, pnodo& nuevo)
{
pnodo ptr = nuevo;
for (;;)
{
if (ptr == NULL)
{
ptr = new nodoArbol();
ptr->info = x;
ptr->izq=ptr->der=NULL;
ptr->repe=1;
return;
}
else
{
if (ptr->info==x)
{
ptr->repe++;
return;
}
if (x < ptr->info)
ptr = ptr->izq;
if (x > ptr->info)
ptr = ptr->der;
}
}
}
pnodo is a data type that basically is a pointer to a tree node. When a repeated data is entered, the repetition of the node (int repe) is increased by 1