Ceil in a Binary Search tree

PHOTO EMBED

Sat Mar 04 2023 10:49:20 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

int findceil(node* root, int key)
{
   int ceil=-1;
   while(root)
   {
      if(root->data==key)
      {
         ceil=key;
         return ceil;
      }
      
      if(root->data<key)
      {
         root=root->right;
      }
      else 
      {
         ceil=root->data;
         root=root->left;
      }
   }
   return ceil;
}
content_copyCOPY

https://youtu.be/KSsk8AhdOZA