Skip to content

Instantly share code, notes, and snippets.

@mrud
Created April 22, 2014 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrud/11178826 to your computer and use it in GitHub Desktop.
Save mrud/11178826 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef struct Tree {
int value;
struct Tree* left;
struct Tree* right;
} Tree;
void print_elem(Tree* root) {
if (root) {
printf("Value: %d\n", root->value);
print_elem(root->left);
print_elem(root->right);
}
}
int main() {
Tree l1 = {1};
Tree l2 = {6};
Tree left = {3, &l1, &l2};
Tree l3 = {9};
Tree l4 = {14};
Tree right = {10, &l3, &l4};
Tree root = {8, &left, &right};
print_elem(&root);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment