如何回答在数组扩展问题中查找重复项?

时间:2016-07-12 13:26:39

标签: algorithm system

我正在进行技术访谈,给出了“在数组中找到重复项”的问题,并且我在O(n)时间内用散列表解决了没有问题,然后我得到了一连串的后续问题。

Orig: Determine if an array contains duplicate entries.

  F1: Now what if the array is very large, and had to be distributed across multiple machines.

  F2: What if the network connection between these machines are prone to failure?

  F3: What if the hardware themselves are not 100% reliable and may occasionally give off wrong answers?

  F4: Design a system so that multiple simultaneous users may need to update this array, while you need to maintain uniqueness of its entries.

我想到F1然后说使用一个巨大的哈希表是不明智的,我们可以将运行时交换到O(n²)以补偿O(1)内存,但不确定其余的。有帮助吗?

1 个答案:

答案 0 :(得分:2)

F2:你必须在不同的机器上复制数据,你可以选择所有数据或部分数据。

F3:在机器之间传输数据时使用校验和值。

F4:使用某种同步(如信号量)确保不同时进行更新。