Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1.     node* poprzednik(node* root, node*& pop, int x)
  2.     {
  3.         if (root == NULL)
  4.         {
  5.             pop = NULL;
  6.             return NULL;
  7.         }
  8.         if (x == root->val)
  9.         {
  10.             if (root->l)
  11.             {
  12.                 pop = max(root->l);
  13.             }
  14.         }
  15.         else if (x < root->val)
  16.         {
  17.             poprzednik(root->l, pop, x);
  18.         }
  19.  
  20.         else
  21.         {
  22.             pop = root;
  23.             poprzednik(root->r, pop, x);
  24.         }
  25.         return pop;
  26.  
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement