I need to calculate h-index from a list of publications stored in a tree.
What I did was move the tree in descending order, getting a list of link position-numbers
it looks like this:
line 1 10 line 2 5 line 3 4 line 4 0
I have to stop at line 3 and return 3. The problem is with the examples given and in this case too
line 1 4 line 2 0 line 3 0
it stops at 2 because 4> 1, but 0> 3 is false. Instead, he should return 1. Can you explain to me why? I know this is more like a math question, but after that I may need to re-implement it if something is deeply mistaken.
Here is the code
int index_h_calc(rbtree_node n, int *i){ if (n == NULL) { fputs("<empty tree>\n", stdout); return 0; } if (n->right != NULL) index_h_calc(n->right,i); graduat *grad; grad=n->value; if(DEBUG) printf("linea %d %d %s\n ",*i,(int)grad->tot,grad->name); if(*i+1>=(int)grad->tot) { return *i; } else *i+=1; if (n->left != NULL) index_h_calc(n->left,i); return *i; }
source share