Beispiel #1
0
 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);
         }
     }
 }
Beispiel #2
0
 public static int getRankOfNumber(int number)
 {
     return(root.getRank(number));
 }