Consider the following
What is the rank(index) of the node $50?$
I found it here pls check & varify.
According to this link https://cs.stackexchange.com/questions/74163/what-is-rank-in-a-binary-search-tree-and-how-can-it-be-useful
shouldnt the rank of 50 be 5 since there are 5 keys that are smaller than 50?
@ Manas Mishra
if I want to find the rank of $60?$
@lakshman use this algo u will get the rank of the node u want
int rank_of(NODE *tree, int val) { int rank = 1; while (tree) { if (val < tree->val) // move to left subtree tree = tree->left; else if (val > tree->val) { rank += 1 + size(tree->left); tree = tree->right; } else return rank + size(tree->left); } return NOT_FOUND; // not found }
Manas Mishra rank of 60 should be 7 right?
@Somoshree Datta 5
Sort the list and you can easily find the rank.
1 2 3 4 5 6 7 8 9 10 11
According to the question, It could be zero-based or 1-based Indexing.
https://stackoverflow.com/questions/26080924/computing-rank-of-a-node-in-a-binary-search-tree
http://www.cs.princeton.edu/courses/archive/spr09/cos423/Lectures/rbtrees.pdf