H-index (Hash Table)

Source: Internet
Author: User

Topic:

Given an array of citations (each citation was a non-negative integer) of a researcher, write a function to compute the RES Earcher ' s h-index. accordingto the definition of H-index on Wikipedia: ' A scientist has index h if h of his/her N papers having at Le AST h citations each, and the other n−h papers has no more than H citations each. "  = [3, 0, 6, 1, 5], which means the researcher have 5 papers in total and each of them had received 3, 0, 6, 1, 5 C Itations respectively.  Since the researcher have 3 papers with at least 3 citations each and the remaining both with no more than 3 citations each, His h-index are 3 for H, and the maximum one is taken as the h-index.

Analysis: With a hash table (auxiliary array), the time complexity is O (N). After constructing the auxiliary array, the traversal begins after the array, and if the total number of paper >= the number of references, the reference number is returned.

The Java code is as follows:

     Public intHindex (int[] citations) {        int[] tmp =New int[Citations.length + 1];  for(inti = 0; i < citations.length; i++) {            if(Citations[i] >=citations.length) {Tmp[citations.length]++; } Else{Tmp[citations[i]]++; }        }        intsum = 0;  for(inti = tmp.length-1; I >= 0; i--) {sum+=Tmp[i]; if(Sum >=i) {returni; }        }        return0; }

H-index (Hash Table)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.