Skip to content

Instantly share code, notes, and snippets.

@mrud mrud/test.c
Created Apr 22, 2014

Embed
What would you like to do?
#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
You can’t perform that action at this time.