Find the largest k numbers in k arrays stored across k machines

前端 未结 7 864
悲哀的现实
悲哀的现实 2020-12-28 19:34

This is an interview question. I have K machines each of which is connected to 1 central machine. Each of the K machines have an array of 4 byte numbers in file. You can use

7条回答
  •  死守一世寂寞
    2020-12-28 20:03

    I would think the MapReduce paradigm would be well suited to a task like this.

    Every machine runs it's own independent map task to find the maximum value in its array (depends on the language used) and this will probably be O(N) complexity for N numbers on each machine.

    The reduce task compares the result from the individual machines' outputs to give you the largest k numbers.

提交回复
热议问题