educative.io

Question regarding the algorithm described in the slides

One of our readers sent us the following feedback:

“Pop two persons from the stack and discard the person who knows the second person ” In the slide, I cannot well understand what’s the reason about it.

Hi,

This is Fatimah Abdullah from Educative. Thank you for reaching out to us!

In response to your feedback, we specified that the celebrity doesn’t know anyone, but everyone knows the celebrity. So, if we compare two people, and one of them knows the other, then it is clear that the person who knew the other can not be the celebrity . Therefore, we discard this person and push the other person back into the stack so it can be compared with the next person. In this way, we will keep narrowing down to the person who is the celebrity. I hope this explanation helps.

Best Regards,
Fatimah Abdullah | Developer Advocate
Educative

1 Like