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
   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.

6 Years
Discussion Span
Last Post by abhimanipal

What happened to all the semi-colons? Have the brackets from your if and else vanished as well, or is the code above your actual code?


no, this is my actual code:

//expresion tree structure
typedef struct nodo_ab{
    int etiqueta;
    lista primerapos;
    lista ultimapos;
    char dato;
    struct nodo_ab* izq;
    struct nodo_ab* der;
    struct nodo_ab* padre;
typedef struct nodo_ab *abb;

typedef struct nodo_pila{
    //int dato;
    struct abb* dato;
    struct nodo_pila *sig;
    } nodo_pila;
typedef nodo_pila *pnodo;
typedef nodo_pila *Pila;

//insert method
void insert(string postfix){
   if (dato!=(concatenacion|opcionalidad|cerradura)){ //if dato is not an operator

   else {
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.