算法导论4-6思考题 VLSI芯片测试

来源:互联网 发布:淘宝店铺推荐男装 编辑:程序博客网 时间:2024/04/29 19:27

Problems 4-6: VLSI chip testing

Start example

Professor Diogenes has n supposedly identical VLSI[1] chips that in principle are capable of testing each other. The professor's test jig accommodates two chips at a time. When the jig is loaded, each chip tests the other and reports whether it is good or bad. A good chip always reports accurately whether the other chip is good or bad, but the answer of a bad chip cannot be trusted. Thus, the four possible outcomes of a test are as follows:

Chip A says

Chip B says

Conclusion


B is good

A is good

both are good, or both are bad

B is good

A is bad

at least one is bad

B is bad

A is good

at least one is bad

B is bad

A is bad

at least one is bad

  1. Show that if more than n/2 chips are bad, the professor cannot necessarily determine which chips are good using any strategy based on this kind of pairwise test. Assume that the bad chips can conspire to fool the professor.

  2. Consider the problem of finding a single good chip from among n chips, assuming that more than n/2 of the chips are good. Show that n/2 pairwise tests are sufficient to reduce the problem to one of nearly half the size.

  3. Show that the good chips can be identified with Θ(n) pairwise tests, assuming that more than n/2 of the chips are good. Give and solve the recurrence that describes the number of tests.

这里我给出b的解法,a好解决,c以b为基础也很容易解决。
分情况考虑
(1)n为偶数
    随机的两两配对,则共有n/2对,分别测试。考虑其中一对的测试结果:如果一好一坏,或者两坏,那么把这对丢弃。这样丢弃不难发现丢弃的好芯片数一定不大于丢弃的坏的芯片数;如果两好(实际情况是两个都是真的好或者两个都是真的坏),那么随意丢弃其中一个,留下一个。
    这样操作后,留下的好的芯片数一定还是大于坏的芯片数的。分析:因为n为偶数,设好的芯片数为a,坏的芯片数为b, 则a-b>=2,由鸽巢原理,必然有一对好的相遇。再往下分析,如果有k对坏的相遇,那么至少再有k对好的相遇,所以两个好相遇的对数一定大于两个坏的相遇的对数。
这样原问题的规模降低一半。

(2)n为奇数

    这个稍微复杂一点。还是随机两两分对,结果必然留下一个没有配对的。同样,结果为一坏一好或者两坏的,直接把这对扔掉,不影响后续判断,现在剩下的对都是两好的,这样对数设为m(如果m=0,则没有配对的那个必然是好的,结束,所以现在假设m不为0),真正两个好的对数设为a,真正两个坏的对数设为b,则a+b=m。
    i) 如果m为奇数
            不难得到a>b,我们可以把那个没有配对的那个扔掉,而直接考虑从这m对中每对任选一个,剩    下的都丢弃。这样需要考虑的有m个芯片,而且其中好的一定多于坏的。
    ii)如果m为偶数
             我们也从m对中,每对中任选一个,这样有m个芯片,再加上刚才没有配对的那个,我们考虑这    m+1个芯片即可。需要证明的是,这m+1个芯片中好的一定多于坏的:如果没有配对的那个是好的,    可以得到a>=b,结论没问题;如果没有配对的那个是坏的,并且m是偶数,所以a>=b+2,我们把这个    坏的就算留下也没有关系,好的还是多于坏的(必须要留下,因为我们不知道没有配对的那个是好的    还是坏的,我们只是证明把最后没有配对的这个留下是没有问题的)。
这样我们就证完了。
原文链接: http://hi.baidu.com/rangemq/blog/item/7d9091ecfb907c2562d09fb1.html