note3_find the celebrity

题目描述:

A guest at a party is a celebrity if this person is known by every other guest, but knows none of them. There is at most one celebrity at a party, for if there were two, they would know each other. A particular party may have no celebrity. Your assignment is to find the celebrity, if one exists, at a party, by asking only one type of question—asking a guest whether they know a second guest. Everyone must answer your questions truthfully. That is, if Alice and Bob are two people at the party, you can ask Alice whether she knows Bob; she must answer correctly. Use mathematical induction to show that if there are n people at the party, then you can find the celebrity, if there is one, with 3(n − 1) questions. [Hint: First ask a question to eliminate one person as a celebrity. Then use the inductive hypothesis to identify a potential celebrity. Finally, ask two more questions to determine whether that person is actually a celebrity.]

 题解:

Basis step - With 2 people at the party, we would need to find out how many questions at most we would need to find a celebrity.

n = 2

2 ≤ 3(2-1)

2 ≤ 3(1)

2 ≤ 3 True. Only 2 questions are needed

 

Induction Hypothesis :

Assuming f(k) is true, so for every k people, you can find a celebrity with >less than 3(k-1) questions, assuming one exists.

Induction Step:

 

 

posted @ 2023-02-15 12:06  哎呦_不想学习哟~  阅读(25)  评论(0)    收藏  举报