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)); } }
public RandomTreeNode FindGreatestNotGreater(int key) { return(root?.FindGreatestNotGreater(key)); }