Tuesday, April 13, 2010

Server allocation for different Online providers

Data is incomplete, but useful. Where is Microsoft, where is amazon, where is yahoo, etc?

1 comment:

  1. Assume the stream of integers is appearing in array 'a'.
    Initialize -
    majority = a[0];
    counter = 1;

    As the number comes in (i=1 onwards) -
    if a[i] == majority -> counter++;
    else if counter == 0 -> majority = a[i];
    else counter--;

    At the end, if there is majority, it is saved in the variable majority.