Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct node
- {
- int data;
- struct node* left;
- struct node* right;
- };
- struct node* createNode(value){
- struct node* newNode = malloc(sizeof(struct node));
- newNode->data = value;
- newNode->left = NULL;
- newNode->right = NULL;
- return newNode;
- }
- struct node* insert(struct node* root, int data)
- {
- if (root == NULL) return createNode(data);
- if (data < root->data)
- root->left = insert(root->left, data);
- else if (data > root->data)
- root->right = insert(root->right, data);
- return root;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement