/* * File: tree1.c * Creator: George Ferguson * * First version of the binary tree program. * Allocates and prints several tree nodes. */ #include #include struct Node { int value; struct Node* leftChild; struct Node* rightChild; }; struct Node* new_Node(int value) { struct Node* this = (struct Node*)malloc(sizeof(struct Node)); if (this == NULL) { return NULL; // Out of memory... } this->value = value; this->leftCHild = NULL; this->rightChild = NULL; return this; } void Node_print(struct Node* this) { printf("Node[%d]", this->value); } int main(int argc, char* argv[]) { struct Node* node1 = new_Node(1); Node_print(node1); struct Node* node2 = new_Node(22); Node_print(node2); struct Node* node3 = new_Node(333); Node_print(node3); }