Skip to main content
added 281 characters in body
Source Link
Pat Devlin
  • 2.7k
  • 16
  • 21

A few quick thoughts.

  1. This is called the group testing problem. If folks wanted to learn more, I suppose they could look it up, and here is a substantial survey on the question (it likely answers whatever you want to know). But that might ruin the fun.

  2. I would really like to say that if you increase $p$, then the best algorithm only gets slower...

  3. The following algorithm works in at most $1 + 2np \log(n)$ steps on average, so for $p \leq n^{-c}$, this matches the information theory lower bound within a multiplicative constant.

(i) Initially test the entire set. (ii) If you test a set, and it contains at least one infected element, then cut the set into two almost equal-sized pieces, and recursively test each piece.

[To analyze that algorithm, perhaps consider the problem where we know that exactly $k$ elements are infected. Then the above algorithm tests at most $1+2k \lceil \lg(n) \rceil$ sets, where $\lg$ is the log base $2$ and $\lceil x \rceil$ denotes the ceiling function (to prove this bound, draw the binary tree of what is tested in this algorithm. Note that each infected element has at most $\lceil \lg(n) \rceil$ sets above it, and each of those contributes at most $2$ tests to the total count). Then just take the expected value of both sides, and we're done since the expected value of $k$ is $np$.]

For larger values of $p$ (e.g., $p = 1 / \log(n)$), I'm not sure what should be the truth. For all $p \geq 1/2$, I would like the answer to be $n$ (see point (1) above).


Added afterwards: I looked at that survey, and I'm kicking myself for not getting the full answer to this. See their Theorem 1.3 which answers your question fully. I suppose I'll post this in a comment to this answer. If you don't want to know, don't look.

A few quick thoughts.

  1. This is called the group testing problem. If folks wanted to learn more, I suppose they could look it up, and here is a substantial survey on the question (it likely answers whatever you want to know). But that might ruin the fun.

  2. I would really like to say that if you increase $p$, then the best algorithm only gets slower...

  3. The following algorithm works in at most $1 + 2np \log(n)$ steps on average, so for $p \leq n^{-c}$, this matches the information theory lower bound within a multiplicative constant.

(i) Initially test the entire set. (ii) If you test a set, and it contains at least one infected element, then cut the set into two almost equal-sized pieces, and recursively test each piece.

[To analyze that algorithm, perhaps consider the problem where we know that exactly $k$ elements are infected. Then the above algorithm tests at most $1+2k \lceil \lg(n) \rceil$ sets, where $\lg$ is the log base $2$ and $\lceil x \rceil$ denotes the ceiling function (to prove this bound, draw the binary tree of what is tested in this algorithm. Note that each infected element has at most $\lceil \lg(n) \rceil$ sets above it, and each of those contributes at most $2$ tests to the total count). Then just take the expected value of both sides, and we're done since the expected value of $k$ is $np$.]

For larger values of $p$ (e.g., $p = 1 / \log(n)$), I'm not sure what should be the truth. For all $p \geq 1/2$, I would like the answer to be $n$ (see point (1) above).

A few quick thoughts.

  1. This is called the group testing problem. If folks wanted to learn more, I suppose they could look it up, and here is a substantial survey on the question (it likely answers whatever you want to know). But that might ruin the fun.

  2. I would really like to say that if you increase $p$, then the best algorithm only gets slower...

  3. The following algorithm works in at most $1 + 2np \log(n)$ steps on average, so for $p \leq n^{-c}$, this matches the information theory lower bound within a multiplicative constant.

(i) Initially test the entire set. (ii) If you test a set, and it contains at least one infected element, then cut the set into two almost equal-sized pieces, and recursively test each piece.

[To analyze that algorithm, perhaps consider the problem where we know that exactly $k$ elements are infected. Then the above algorithm tests at most $1+2k \lceil \lg(n) \rceil$ sets, where $\lg$ is the log base $2$ and $\lceil x \rceil$ denotes the ceiling function (to prove this bound, draw the binary tree of what is tested in this algorithm. Note that each infected element has at most $\lceil \lg(n) \rceil$ sets above it, and each of those contributes at most $2$ tests to the total count). Then just take the expected value of both sides, and we're done since the expected value of $k$ is $np$.]

For larger values of $p$ (e.g., $p = 1 / \log(n)$), I'm not sure what should be the truth. For all $p \geq 1/2$, I would like the answer to be $n$ (see point (1) above).


Added afterwards: I looked at that survey, and I'm kicking myself for not getting the full answer to this. See their Theorem 1.3 which answers your question fully. I suppose I'll post this in a comment to this answer. If you don't want to know, don't look.

added 147 characters in body
Source Link
Pat Devlin
  • 2.7k
  • 16
  • 21

A few quick thoughts.

  1. This is called the group testing problem. If folks wanted to learn more, I suppose they could look it up, butand here is a substantial survey on the question (it likely answers whatever you want to know). But that might ruin the fun.

  2. I would really like to say that if you increase $p$, then the best algorithm only gets slower...

  3. The following algorithm works in at most $1 + 2np \log(n)$ steps on average, so for $p \leq n^{-c}$, this matches the information theory lower bound within a multiplicative constant.

(i) Initially test the entire set. (ii) If you test a set, and it contains at least one infected element, then cut the set into two almost equal-sized pieces, and recursively test each piece.

[To analyze that algorithm, perhaps consider the problem where we know that exactly $k$ elements are infected. Then the above algorithm tests at most $1+2k \lceil \lg(n) \rceil$ sets, where $\lg$ is the log base $2$ and $\lceil x \rceil$ denotes the ceiling function (to prove this bound, draw the binary tree of what is tested in this algorithm. Note that each infected element has at most $\lceil \lg(n) \rceil$ sets above it, and each of those contributes at most $2$ tests to the total count). Then just take the expected value of both sides, and we're done since the expected value of $k$ is $np$.]

For larger values of $p$ (e.g., $p = 1 / \log(n)$), I'm not sure what should be the truth. For all $p \geq 1/2$, I would like the answer to be $n$ (see point (1) above).

A few quick thoughts.

  1. This is called the group testing problem. If folks wanted to learn more, I suppose they could look it up, but that might ruin the fun.

  2. I would really like to say that if you increase $p$, then the best algorithm only gets slower...

  3. The following algorithm works in at most $1 + 2np \log(n)$ steps on average, so for $p \leq n^{-c}$, this matches the information theory lower bound within a multiplicative constant.

(i) Initially test the entire set. (ii) If you test a set, and it contains at least one infected element, then cut the set into two almost equal-sized pieces, and recursively test each piece.

[To analyze that algorithm, perhaps consider the problem where we know that exactly $k$ elements are infected. Then the above algorithm tests at most $1+2k \lceil \lg(n) \rceil$ sets, where $\lg$ is the log base $2$ and $\lceil x \rceil$ denotes the ceiling function (to prove this bound, draw the binary tree of what is tested in this algorithm. Note that each infected element has at most $\lceil \lg(n) \rceil$ sets above it, and each of those contributes at most $2$ tests to the total count). Then just take the expected value of both sides, and we're done since the expected value of $k$ is $np$.]

For larger values of $p$ (e.g., $p = 1 / \log(n)$), I'm not sure what should be the truth. For all $p \geq 1/2$, I would like the answer to be $n$ (see point (1) above).

A few quick thoughts.

  1. This is called the group testing problem. If folks wanted to learn more, I suppose they could look it up, and here is a substantial survey on the question (it likely answers whatever you want to know). But that might ruin the fun.

  2. I would really like to say that if you increase $p$, then the best algorithm only gets slower...

  3. The following algorithm works in at most $1 + 2np \log(n)$ steps on average, so for $p \leq n^{-c}$, this matches the information theory lower bound within a multiplicative constant.

(i) Initially test the entire set. (ii) If you test a set, and it contains at least one infected element, then cut the set into two almost equal-sized pieces, and recursively test each piece.

[To analyze that algorithm, perhaps consider the problem where we know that exactly $k$ elements are infected. Then the above algorithm tests at most $1+2k \lceil \lg(n) \rceil$ sets, where $\lg$ is the log base $2$ and $\lceil x \rceil$ denotes the ceiling function (to prove this bound, draw the binary tree of what is tested in this algorithm. Note that each infected element has at most $\lceil \lg(n) \rceil$ sets above it, and each of those contributes at most $2$ tests to the total count). Then just take the expected value of both sides, and we're done since the expected value of $k$ is $np$.]

For larger values of $p$ (e.g., $p = 1 / \log(n)$), I'm not sure what should be the truth. For all $p \geq 1/2$, I would like the answer to be $n$ (see point (1) above).

Source Link
Pat Devlin
  • 2.7k
  • 16
  • 21

A few quick thoughts.

  1. This is called the group testing problem. If folks wanted to learn more, I suppose they could look it up, but that might ruin the fun.

  2. I would really like to say that if you increase $p$, then the best algorithm only gets slower...

  3. The following algorithm works in at most $1 + 2np \log(n)$ steps on average, so for $p \leq n^{-c}$, this matches the information theory lower bound within a multiplicative constant.

(i) Initially test the entire set. (ii) If you test a set, and it contains at least one infected element, then cut the set into two almost equal-sized pieces, and recursively test each piece.

[To analyze that algorithm, perhaps consider the problem where we know that exactly $k$ elements are infected. Then the above algorithm tests at most $1+2k \lceil \lg(n) \rceil$ sets, where $\lg$ is the log base $2$ and $\lceil x \rceil$ denotes the ceiling function (to prove this bound, draw the binary tree of what is tested in this algorithm. Note that each infected element has at most $\lceil \lg(n) \rceil$ sets above it, and each of those contributes at most $2$ tests to the total count). Then just take the expected value of both sides, and we're done since the expected value of $k$ is $np$.]

For larger values of $p$ (e.g., $p = 1 / \log(n)$), I'm not sure what should be the truth. For all $p \geq 1/2$, I would like the answer to be $n$ (see point (1) above).