public int getRank(int d) { if (d == data) { return(left_size); } else if (d < data) { if (left == null) { return(-1); } else { return(left.getRank(d)); } } else { int right_rank = right == null ? -1 : right.getRank(d); if (right_rank == -1) { return(-1); } else { return(left_size + 1 + right_rank); } } }
public static int getRankOfNumber(int number) { return(root.getRank(number)); }