Question

There are 'n' number of detectives..each one knows an information, how many minimum calls should they make so all the detectives know all the n number of information ?

My answer: I came up with 2n-3 (that is, n-1 + n-2) solution where a detective calls n-1 other detectives and shares information mutually (in this way the last detective and the first has all the information). Then the remaining n-2 detectives who doesn't have the whole data calls either the first detective or the last to gain the remaining information.

(This is a question asked by my friend).

Was it helpful?

Solution

2n-3 is not correct.

Consider the case of n=4, 2n-3 would predict that 2*4-3=5 calls are needed.

However, we can do it in 4 calls via:

A calls B
C calls D
A calls C
B calls D
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top