Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. printf("Enter a number to search: ");
  2. scanf("%d", &num);
  3. if (search(root, num) != NULL) {
  4. printf("YESn");
  5. }
  6. else {
  7. printf("NOn");
  8. }
  9.  
  10. BST* search(BST* root, int value) {
  11. if( root == NULL) {
  12. return NULL;
  13. }
  14. else if(value < root->value) {
  15. root->left = search(root->left, value);
  16. }
  17. else if(value > root->value) {
  18. root->right = search(root->right, value);
  19. }
  20. return root;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement