Quick actions

cmd+k|ctrl+k

Navigation

Languages

Reverse Binary Tree (2B version)

Snippet info

Language

C

Visibility

public

Author

hyrious

Created

2019-04-04T12:56:16Z

Updated

2019-04-04T12:56:16Z

#include <stdio.h>
struct Node {
    struct Node *left;
    int data;
    struct Node *right;
};

struct Deno {
    struct Deno *right;
    int data;
    struct Deno *left;
};

void print(struct Deno *r) {
    if (!r) return;
    print(r->left);
    printf("%d\n", r->data);
    print(r->right);
}

int main(void) {
    struct Node left  = { NULL, 0, NULL };
    struct Node right = { NULL, 2, NULL };
    struct Node root  = { &left, 1, &right }; // 0 -- 1 -- 2
    print((struct Deno*)&root); // 2 1 0
}
INFO