March 9, 2010

There are N secret agents each know a different piece of secret information. They can telephone each other and exchange all the information they know. After the telephone call, they both know anything that either of them knew before the call. What are the minimum number of telephone calls needed so that all of them know everything?

i think 2n-2 because everyone calls one person and shares their info (n-1) phone calls, then that person calls everyone back with all the info (n-1) phone calls, so (n-1)+(n-1)= 2n-2. I don't know if there's a more efficient way, but I'm not sure how everyone can have all the info with just n-1 phone calls

To start with, let us say how many calls does one take in case of 4 folks::

1 2 3 4=== ===Group1 Group2Now 1 and 2 talk, 3 and 4 talkAs such,

1-> knows (1 and 2) 2 -> 12

3-> 344-> 34

Now say 1 from Group1 and 4 from Group2 talk.

Now the case is

1> 12 +34 = 12344-> 12 + 34 = 1234

Now let 2 and 3 talk,

After this again

3-> 34 + 12 = 12344-> 34 + 12 = 1234

So in a group of 4 only 4 converstaions need to be done to let everybody know of the other 3 folks' secret.

Now take the case of 5,

1234 5Group1 Group2

Suppose 4 talks to 5 and gets his secret. Now let the group of 4 ( Group 1) talk among themselves.So 4 convs need to be made to let 1,2,3,4 know -> 1234 + 5'secret.

Now 4 goes and talks to 5 . Now everybody knows everybody's secret.

Total convos = 1 + 4 + 1 = 6

This can be best visualised like this ::

------| 1234 | --> 5 <-- ------4 convos + 2 convos

For 6

------| 1234 | --> 5 --> 6 <-- <-- ------

4 + 2 + 2

In case of 6, let 6 talk to 5, then 5 talks to 4 , now let the group of 4 talk to each other. After these 6 calls, 1234 know - > 123456 . After that 4 ( from 1234) talks to 5 ( here 5 knows -> 123456 ). And then 5 talks to 6 (or 4 to 6) (after this 6 too knows 123456 )

i think the answer would be..2n-3..for minimum nos of calls all of the agents must call to a particular agent so total nos of calls to that agent will be (n-1)..nd now this agent nd the agent calling last has full information...now the other left out agents (n-2) must again phone to him nd gather the full information....sototal nos of calls= (n-1)+(n-2)=2n-3

Thereafter, each time you add an agent to the previous group of agents, two extra conversations are required - one at the start between the last added agent and a member of the previously established group, and one at the end between the last added agent and the group.