Created
September 21, 2022 12:11
-
-
Save dharmx/5aa11ffbcf8d88dace84fbc3770293d6 to your computer and use it in GitHub Desktop.
A node of a BST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct node_t node_t; | |
struct node_t { | |
int data; | |
node_t* left; | |
node_t* right; | |
}; | |
int | |
main(void) { | |
node_t root; | |
node_t left; | |
node_t left_left; | |
node_t left_right; | |
node_t right; | |
root.data = 10; | |
left.data = 11; | |
left_left.data = 124; | |
left_right.data = 89; | |
right.data = 19; | |
root.right = &right; | |
root.left = &left; | |
left.left = &left_left; | |
left.right = &left_right; | |
printf(" %d\n" | |
" |\n" | |
" / \\\n" | |
" %d %d\n" | |
" |\n" | |
" / \\\n" | |
"%d %d\n", | |
root.data, | |
root.left->data, | |
root.right->data, | |
root.left->left->data, | |
root.left->right->data); | |
return 0; | |
} | |
// vim:filetype=c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment