精明与糊涂
有N个人,分为两类:
● i) 精明人:永远能正确判断其他人是精明还是糊涂;
● ii) 糊涂人:判断不可靠,会给出随机的判断。
已知精明人严格占据多数,即如果精明人有k个,则满足k>N/2k > N/2k>N/2 。
你只能通过函数query(i,j) 让第 i 个人判断第 j 个人:返回true表示判断结果为“精明人”;返回false表示判断结果为“糊涂人”。你的目标是通过互相判断,找出至少一个百分之百能确定的精明人。同时,你无需关心 query(i,j)的内部实现。
以下程序利用“精明人占多数”的优势,通过“消除”过程让人们互相判断并进行抵消,经过若干轮抵消后,最终留下的候选者必然属于多数派,即精明人。
例如,假设有三个人 0、1、2。如果0说1是糊涂人,而1也说0是糊涂人,则0和1至少有一个是糊涂人。程序将同时淘汰0和1。由于三人里至少有两个精明人,我们确定2是精明人。
0 of 5 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 5 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
①处应填( )
②处应填( )
③处应填( )
④处应填( )
⑤处应填( )
