Originally Posted by
john_12
And what is the easiest way to build a full binary tree with the least amount of code?
Just put the data in as initializers.
Code:
struct Node {
struct Node *left;
struct Node *right;
char payload;
};
struct Node * Tree_root = &(struct Node){
.payload='D',
.left = &(struct Node){
.payload='B',
.left=&(struct Node){.payload='A' },
.right=&(struct Node){.payload='C'},
},
.right = &(struct Node) {
.payload='F',
.left=&(struct Node){.payload='E' },
.right=&(struct Node){.payload='G'},
},
}