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; } }
int getRank(int d) { if (d == data) { return left_size; } else if (d < data) { if (left == nullptr) { return -1; } else { return left->getRank(d); } } else { int right_rank = right == nullptr ? -1 : right->getRank(d); if (right_rank == -1) return -1; else return left_size + 1 + right_rank; } }
int getRankOfNumber(int number) { return root->getRank(number); }