Exemplo n.º 1
0
 public RandomTreeNode FindGreatestNotGreater(int k, RandomTreeNode max = null)
 {
     if (key < k && (max == null || key > max.key))
     {
         max = this;
     }
     if (k == key)
     {
         return(this);
     }
     if (k < key)
     {
         return(left == null ? max : left.FindGreatestNotGreater(k, max));
     }
     else
     {
         return(right == null ? max : right.FindGreatestNotGreater(k, max));
     }
 }
Exemplo n.º 2
0
 public RandomTreeNode FindGreatestNotGreater(int key)
 {
     return(root?.FindGreatestNotGreater(key));
 }