欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Google Interview - Compute the h-index of a

系統(tǒng) 2513 0

Google:

Compute the h-index of a list of papers, given their citation count. Can you do it in linear time? How about a distributed algorithm for the task?

?

Facebook:

Given: for every paper authored, there is a citation count vector. The h-index is a measure of researcher importance. h-index: The largest number i such that there are i papers each with at least i citations.?

1. Suppose that the citation-vector is sorted, how to efficiently compute the h-index??

2. Suppose that the citation-vector is not sorted, how to efficiently compute the h-index? time complexity? an algorithm with time complexity n?

?

Princeton algorithm:

Given an array of N positive integers, its h-index is the largest integer h such that there are at least h entries in the array greater than or equal to h. Design an algorithm to compute the h-index of an array.?

Hint: median or quicksort-like partitioning and divide-and-conquer.

?

Solution:

- Create an int[] Histogram as big as the maximum number of publications of any particular scientist).?

- If all publication reference counts are stored in another int[] references, then go over this array and, on each publication, if it's reference count is R, then do Histogram[R]++. While doing this, keep the maximum reference count in Max.?

- After building the histogram, do a decreasing loop on int[] Histogram from i=Max, adding Histogram[i] values to int hIndex. When hIndex >= i, return i as the hIndex.?

... As to the distributed part, let several machines build the Histogram of disjoint sets of somebody's publications, and then have one machine add up those histograms and return hIndex as described above.

?

1. binary-search (O(log(n)). If citations[i] >= i then h >= i (if array's in descending order).

2. Here's a O(n) time & space solution in ruby. The trick is you can ignore citation-counts larger than n.

?

If there are 'n' papers in total, this problem can be solved in O(n) with space complexity of O(n). Note that, h-index can be between 0 to n. Say if the h-index is 10, this means, there has to be 10 papers with citation count >= 10. So if we can find out the number of papers with citations >=X for every X (and store it in an array C) where X ranges between 0 to n, then by scanning the count array C from the right to left, we can find the h-index at index i where i == C[i].?

Pseudocode:?
input array A of length n.?

- init array C[0] to C[n] with 0?
- foreach p in A, if p >= n, c[n]++; else c[p] +=1?
- for i=n-1 to 0, c[i]=c[i]+c[i+1]?
- for i=n to 0, if c[i] == i return i

?

      // assume sorted in descending order, O(lgN)
public static int getHIndexFromSorted(int[] citation) {
    int low = 0; int high = citation.length - 1;
    while(low <= high) {
        int idx = (low+high)/2;
        if(citation[idx] >= idx + 1) {
            low = idx + 1;
        } else {
            high = idx - 1;
        }
    }
    return low;
}

// sort the array, O(NlgN)
public static int computeHIndexBySorting(int[] A) {
    Arrays.sort(A);
    int h = 0;
    for (int i = A.length-1; i >= 0; i--) {
        if(A[i] > h) {
            h++;
        } else {
            return h;
        }
    }
    return -1;
}

// no need to sort array, O(N)
public static int computeHIndex(int[] A) {
    int n = A.length;
    int[] s = new int[n+1];
    for(int num : A) {
        num = Math.min(n ,num);
        s[num]++;
    }
    int sum = 0;
    for (int i = s.length-1; i >= 0; i--) {
        sum += s[i];
        if(sum >= i) {
            return i;
        }
    }
    return -1;
}
    

?

?

Reference:

http://en.wikipedia.org/wiki/H-index

http://www.careercup.com/question?id=14585874

http://algs4.cs.princeton.edu/25applications/

http://www.glassdoor.com/Interview/Compute-the-h-index-of-a-list-of-papers-given-their-citation-count-Can-you-do-it-in-linear-time-How-about-a-distributed-QTN_572531.htm

?

Google Interview - Compute the h-index of a list of papers


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 欧美性猛交一区二区三区精品 | 邪不压正免费观看完整高清视频 | 人人爱免费在线观看 | 日本一区二区三区视频在线观看 | 99久热国产精品视频尤物不卡 | 国产美女一区二区 | 国产成人在线视频播放 | 久久国产色| 久久亚洲私人国产精品 | 欧美精品成人一区二区三区四区 | 一区二区三区四区五区中文字幕 | 亚洲精品人人 | 三级视频在线播放 | 亚洲成人免费视频在线观看 | 精品国产91乱码一区二区三区 | 免费伊人网 | 国产日韩欧美一区 | 99热视 | 毛片1毛片2毛片3毛片4 | 精品久久久久久无码中文字幕 | 91精品午夜 | 一区二区久久 | 国产精品三级久久久久久电影 | 夜夜操网 | 日韩视频专区 | 毛片成人永久免费视频 | 99热最新网址| 免费av一区二区三区 | 欧美久久xxxxxx影院 | 综合网天天色 | 无码日本亚洲一区久久精品 | 国产福利91精品一区二区三区 | 中文字幕 国产精品 | 国产二区三区四区 | 天天鲁天天爽天天视频 | 欧美精品 在线播放 | www.日韩在线 | 婷婷国产在线观看 | 成人无码T髙潮喷水A片小说 | 全免费A敌肛交毛片免费 | 亚婷婷洲AV久久蜜臀无码 |