H-index calculation

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; } 
+6
source share
2 answers

This has several solutions on github , for example in Ruby, which is equivalent to your n is citePages and is h-index calculated

 function h_index(){ var hArray = new Array(); var x = 0; for(var i = 0; i < citePages.length; i++){ var citeArray = citePages[i]; for(var j = 0; j < citeArray.length; j++){ // The multiplication by one is a hack to convert the string type into a numerical type hArray[x++] = citeArray[j]*1; } } hArray.sort(sortNumber); //alert(hArray); for(var i = 0; i < hArray.length; i++){ if(i > hArray[i]){ return hArray[i-1]; } } } 

previous function -

 function getCitationCount(responseText){ if (responseText == null){ _gel("sContent").innerHTML = "<i>Invalid data.</i>"; alert("There is no data."); return; } var cite_exists = 1; var cite_str_len = 14; var len_of_Cite_by_str = 9; var citeArray = new Array(); for(var i = 0; cite_exists > 0; i++) { cite_exists = responseText.search('Cited by'); if(cite_exists == -1){ //alert("No more citations for given Author!"); //return; }else{ var tmp_string = responseText.substr(cite_exists, cite_str_len); var end = (tmp_string.indexOf("<")-len_of_Cite_by_str); citeArray[i] = tmp_string.substr(len_of_Cite_by_str, end); publications++; responseText = responseText.substr(cite_exists+cite_str_len, responseText.length); } } return citeArray; } 

If this does not provide a solution, then the problem should be a check - so we really need example data, for example, jsfiddle of typical data, which indicates what result is expected in each case, given that this is a mathematical question, not an encoding one and can be tested only with a complex data structure filled in.

0
source

I may be lacking in some subtlety, but this is not an answer to subtract from the line number? That is, if i is the line number and n is the number of quotes, you cross the tree until you find a line with n < i , and then return h-index as i - 1 .

0
source

Source: https://habr.com/ru/post/890278/


All Articles