Considering the following c code:
typedef struct ELE *tree_ptr
struct ELE {
long val;
tree_ptr left;
tree_ptr right;
};
I believe ELE encapsulates a single node of a binary tree. Each node has some 32-bit value(val), a pointer to a left node, and a pointer to a right node.
Can someone confirm that my interpretation is correct?
Also, is ELE just an arbitrary variable name or some convention used to name a struct?
edit:
What if there was a c program that generated the following 3 lines of assembly code:
movq %rbx, -24(%rsp)
movq %rbp, -16(%rsp)
movq %r12, -8(%rsp)
Are these 3 lines making room for the 3 elements of the struct on the stack?
That would most likely be
ELEment, one element of the collection.A few other points to consider:
typedefneeds a semicolon at the end.longintegers are 32 bits.tree_ptrindicates that it probably is a binary tree but all you know for sure is that it’s a structure containing alongand the two pointers to the same type as the structure. It may well be a doubly-linked list if the coder that put it together was deranged or sadistic enough 🙂