hi. Im trying to make an expresion tree for every ER that I read
each ER will be transformed into postfix and saved in a string, which I'll be sending to arbol_expresion() to create it`s tree expression
Searching on the web I found a method to convert the postfix expresion to a tree, which says that I have to remember the two nodes, and then, when I read an operator, I assign the two nodes as its childs
I was thinking that the easiest way to do that is by a stack: I create the nodes and save them into the stack, when I read the operator, I read the stack //which contains the pointers to the two nodes
and assign them to the operator's node.
This are my structures:
struct node_ab{ //expression tree structure
struct node_ab* izq //left child
struct node_ab* der
struct list primerapos
struct list ultimapos
int etiqueta
};
typedef struct node_ab abb
struct pila{ //stack
struct abb* dato
struct pila *siguiente
}
void insert(string postfix){
if dato!=concatenacion|opcionalidad|cerradura //if dato is not an operator
create node //here I set all the pointers of the node
pila.push(*node)
else
crear nodo //here I set all the pointers of the node
nodo->izq= pila.pop()
nodo->der= pila.pop()
I dont know what is happening, because it says that I'm working with two different type of variables when I assign the pointers of the nodes saved in the stack to the operator node.