Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 10: You are given a set P of n people, where n21. A person p P is called a very important person (VIP), if
Question 10: You are given a set P of n people, where n21. A person p P is called a very important person (VIP), if all other persons in P know p, but p does not know anybody in P (besides him/herself). Give a recursive algorithm that returns a VIP in P, if a VIP exist:s, nil, if there is no VIP in P. The running time of your algorithm must be O(n) You are only allowed to use the operation DoYoUKNow, which takes two arbitrary persons p and q in P, with p ^ q, and returns the value DoYockNow(p.q)= { true if p knows q, false if p does not know q. Observe that DoYouKNow(p, q) need not be equal to DoYouKnow(q, p)'. "DoYouKNOw(Michiel,Mick Jagger) = true, but DoYouKNOw(Mick Jagger,Michiel)-fase Argue why your algorithm is correct, and why its running time is O(n) Hint: If DoYouKNOW(p, q)- true, then p is not a VIP; if DoYoUKNow(p, q) -false, then q is not a VIP. Question 10: You are given a set P of n people, where n21. A person p P is called a very important person (VIP), if all other persons in P know p, but p does not know anybody in P (besides him/herself). Give a recursive algorithm that returns a VIP in P, if a VIP exist:s, nil, if there is no VIP in P. The running time of your algorithm must be O(n) You are only allowed to use the operation DoYoUKNow, which takes two arbitrary persons p and q in P, with p ^ q, and returns the value DoYockNow(p.q)= { true if p knows q, false if p does not know q. Observe that DoYouKNow(p, q) need not be equal to DoYouKnow(q, p)'. "DoYouKNOw(Michiel,Mick Jagger) = true, but DoYouKNOw(Mick Jagger,Michiel)-fase Argue why your algorithm is correct, and why its running time is O(n) Hint: If DoYouKNOW(p, q)- true, then p is not a VIP; if DoYoUKNow(p, q) -false, then q is not a VIP
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started