Guest User

Untitled

a guest
Oct 30th, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. struct TreeNode
  2. {
  3.    int value;
  4.    TreeNode *leftChild;
  5.    TreeNode *rightChild;
  6. };
  7.  
  8. struct Tree
  9. {
  10.     TreeNode *root;
  11. };
  12.  
  13. TreeNode **search(TreeNode *&currentNode, int x)
  14. {
  15.     if (currentNode == NULL)
  16.         return NULL;
  17.     if (x == currentNode->value)
  18.         return &currentNode;
  19.     if (x < currentNode->value)
  20.         return search(currentNode->leftChild, x);
  21.     else
  22.         return search(currentNode->rightChild, x);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment