Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- printf("Enter a number to search: ");
- scanf("%d", &num);
- if (search(root, num) != NULL) {
- printf("YESn");
- }
- else {
- printf("NOn");
- }
- BST* search(BST* root, int value) {
- if( root == NULL) {
- return NULL;
- }
- else if(value < root->value) {
- root->left = search(root->left, value);
- }
- else if(value > root->value) {
- root->right = search(root->right, value);
- }
- return root;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement