grigory51

find

May 22nd, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. node* find(node* start, int key) {
  2.     if (start == NULL) {
  3.         return NULL;
  4.     }  
  5.     if (key == start->key) {
  6.         return start;
  7.     }
  8.     else {
  9.         if (key > start->key) {
  10.             return find(start->r, key);
  11.         }
  12.         if (key < start->key) {
  13.             return find(start->l, key);
  14.         }
  15.     }
  16.    
  17. }
Advertisement
Add Comment
Please, Sign In to add comment