How can the sniffer dog find the bag of drugs?
$begingroup$
There are $n$ bags. In one of the bags are drugs. There is a dog that when given a group of bags, can tell whether there are drugs in the group or not. Each sniff counts as a "turn". What is the best strategy, the strategy that find the bag with drugs in the smallest amount of turns?
So for example, say there are $60$ bags and the drugs are in bag $5$. The dog sniffs bags $17, 6, 2$ and determines that there are no drugs in them. If the dog sniffs in bags $30, 35,5$ then the dog confirms that the drugs are in that group of bags.
I think that the best strategy is to sniff half of the bags at a time. So when $n=60$, the dog would sniff thirty bags in the first turn, 15 bags in the second turn, 8 bags in the third turn and so on, eventually finding the one bag with drugs in it.
But how can I prove that it is the best strategy? Thanks.
combinatorics discrete-mathematics algorithms recreational-mathematics
$endgroup$
add a comment |
$begingroup$
There are $n$ bags. In one of the bags are drugs. There is a dog that when given a group of bags, can tell whether there are drugs in the group or not. Each sniff counts as a "turn". What is the best strategy, the strategy that find the bag with drugs in the smallest amount of turns?
So for example, say there are $60$ bags and the drugs are in bag $5$. The dog sniffs bags $17, 6, 2$ and determines that there are no drugs in them. If the dog sniffs in bags $30, 35,5$ then the dog confirms that the drugs are in that group of bags.
I think that the best strategy is to sniff half of the bags at a time. So when $n=60$, the dog would sniff thirty bags in the first turn, 15 bags in the second turn, 8 bags in the third turn and so on, eventually finding the one bag with drugs in it.
But how can I prove that it is the best strategy? Thanks.
combinatorics discrete-mathematics algorithms recreational-mathematics
$endgroup$
add a comment |
$begingroup$
There are $n$ bags. In one of the bags are drugs. There is a dog that when given a group of bags, can tell whether there are drugs in the group or not. Each sniff counts as a "turn". What is the best strategy, the strategy that find the bag with drugs in the smallest amount of turns?
So for example, say there are $60$ bags and the drugs are in bag $5$. The dog sniffs bags $17, 6, 2$ and determines that there are no drugs in them. If the dog sniffs in bags $30, 35,5$ then the dog confirms that the drugs are in that group of bags.
I think that the best strategy is to sniff half of the bags at a time. So when $n=60$, the dog would sniff thirty bags in the first turn, 15 bags in the second turn, 8 bags in the third turn and so on, eventually finding the one bag with drugs in it.
But how can I prove that it is the best strategy? Thanks.
combinatorics discrete-mathematics algorithms recreational-mathematics
$endgroup$
There are $n$ bags. In one of the bags are drugs. There is a dog that when given a group of bags, can tell whether there are drugs in the group or not. Each sniff counts as a "turn". What is the best strategy, the strategy that find the bag with drugs in the smallest amount of turns?
So for example, say there are $60$ bags and the drugs are in bag $5$. The dog sniffs bags $17, 6, 2$ and determines that there are no drugs in them. If the dog sniffs in bags $30, 35,5$ then the dog confirms that the drugs are in that group of bags.
I think that the best strategy is to sniff half of the bags at a time. So when $n=60$, the dog would sniff thirty bags in the first turn, 15 bags in the second turn, 8 bags in the third turn and so on, eventually finding the one bag with drugs in it.
But how can I prove that it is the best strategy? Thanks.
combinatorics discrete-mathematics algorithms recreational-mathematics
combinatorics discrete-mathematics algorithms recreational-mathematics
asked Dec 3 '14 at 1:08
JoaoJoao
94631134
94631134
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
If we have $n$ bags, we will need $k = log_2{n}$ turns to figure out which bag has the drugs.
The procedure would be similar to what you said in the first step.
Let us number each bag and represent this number in binary system. First turn would be first half bags, i.e., bags with $1$-th MSB equal to 1 (i.e., the first MSB from the leading edge), second turn would be another half set of bags which have $2$-th MSB equal to 1, and so on. In general, $m$-th turn would be all the bags with numbers which have the $m$-th MSB equal to 1.
We cannot beat $k = log_2{n}$ turns, since each outcome of sniffing is binary and as we need $log_2{n}$ bits to represent $n$ bags.
$endgroup$
4
$begingroup$
It might be more convincing to use integer counting. There are 60 possible outcomes (only one bag out of 60 has drugs). Therefore six tests are needed in the "worst" case, because five tests cannot discriminate 60 possibilities.
$endgroup$
– hardmath
Dec 3 '14 at 3:22
add a comment |
$begingroup$
This kind of problem, "what is the least number of questions I need to ask to solve a problem?", is a topic addressed by information theory. The total information content is
$$
H=1/60log_2(1/60)approx5.9 {rm bits.}
$$
Six bits of information mean we need to ask at least six yes/no questions (six sniffs of the bags) to find the stuff. Thus since it achieves the maximum, your strategy is optimal.
There is some more and a reference in another answer I wrote.
Incidentally I don't think dogs can sniff out 30 bags at once in reality.
$endgroup$
$begingroup$
+1 for the reality comment. The problem as the OP stated is a non-practical one. Similar would be the idea of searching for the one black marble out of a batch of several hundred white marbles. The marbles are in leather pouches and when you look in the pouch you cannot be certain if the black marble is hidden in the bottom of the pouch or not.
$endgroup$
– Michael Karas
May 1 '16 at 11:38
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1049152%2fhow-can-the-sniffer-dog-find-the-bag-of-drugs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
If we have $n$ bags, we will need $k = log_2{n}$ turns to figure out which bag has the drugs.
The procedure would be similar to what you said in the first step.
Let us number each bag and represent this number in binary system. First turn would be first half bags, i.e., bags with $1$-th MSB equal to 1 (i.e., the first MSB from the leading edge), second turn would be another half set of bags which have $2$-th MSB equal to 1, and so on. In general, $m$-th turn would be all the bags with numbers which have the $m$-th MSB equal to 1.
We cannot beat $k = log_2{n}$ turns, since each outcome of sniffing is binary and as we need $log_2{n}$ bits to represent $n$ bags.
$endgroup$
4
$begingroup$
It might be more convincing to use integer counting. There are 60 possible outcomes (only one bag out of 60 has drugs). Therefore six tests are needed in the "worst" case, because five tests cannot discriminate 60 possibilities.
$endgroup$
– hardmath
Dec 3 '14 at 3:22
add a comment |
$begingroup$
If we have $n$ bags, we will need $k = log_2{n}$ turns to figure out which bag has the drugs.
The procedure would be similar to what you said in the first step.
Let us number each bag and represent this number in binary system. First turn would be first half bags, i.e., bags with $1$-th MSB equal to 1 (i.e., the first MSB from the leading edge), second turn would be another half set of bags which have $2$-th MSB equal to 1, and so on. In general, $m$-th turn would be all the bags with numbers which have the $m$-th MSB equal to 1.
We cannot beat $k = log_2{n}$ turns, since each outcome of sniffing is binary and as we need $log_2{n}$ bits to represent $n$ bags.
$endgroup$
4
$begingroup$
It might be more convincing to use integer counting. There are 60 possible outcomes (only one bag out of 60 has drugs). Therefore six tests are needed in the "worst" case, because five tests cannot discriminate 60 possibilities.
$endgroup$
– hardmath
Dec 3 '14 at 3:22
add a comment |
$begingroup$
If we have $n$ bags, we will need $k = log_2{n}$ turns to figure out which bag has the drugs.
The procedure would be similar to what you said in the first step.
Let us number each bag and represent this number in binary system. First turn would be first half bags, i.e., bags with $1$-th MSB equal to 1 (i.e., the first MSB from the leading edge), second turn would be another half set of bags which have $2$-th MSB equal to 1, and so on. In general, $m$-th turn would be all the bags with numbers which have the $m$-th MSB equal to 1.
We cannot beat $k = log_2{n}$ turns, since each outcome of sniffing is binary and as we need $log_2{n}$ bits to represent $n$ bags.
$endgroup$
If we have $n$ bags, we will need $k = log_2{n}$ turns to figure out which bag has the drugs.
The procedure would be similar to what you said in the first step.
Let us number each bag and represent this number in binary system. First turn would be first half bags, i.e., bags with $1$-th MSB equal to 1 (i.e., the first MSB from the leading edge), second turn would be another half set of bags which have $2$-th MSB equal to 1, and so on. In general, $m$-th turn would be all the bags with numbers which have the $m$-th MSB equal to 1.
We cannot beat $k = log_2{n}$ turns, since each outcome of sniffing is binary and as we need $log_2{n}$ bits to represent $n$ bags.
answered Dec 3 '14 at 2:39
ShashShash
80157
80157
4
$begingroup$
It might be more convincing to use integer counting. There are 60 possible outcomes (only one bag out of 60 has drugs). Therefore six tests are needed in the "worst" case, because five tests cannot discriminate 60 possibilities.
$endgroup$
– hardmath
Dec 3 '14 at 3:22
add a comment |
4
$begingroup$
It might be more convincing to use integer counting. There are 60 possible outcomes (only one bag out of 60 has drugs). Therefore six tests are needed in the "worst" case, because five tests cannot discriminate 60 possibilities.
$endgroup$
– hardmath
Dec 3 '14 at 3:22
4
4
$begingroup$
It might be more convincing to use integer counting. There are 60 possible outcomes (only one bag out of 60 has drugs). Therefore six tests are needed in the "worst" case, because five tests cannot discriminate 60 possibilities.
$endgroup$
– hardmath
Dec 3 '14 at 3:22
$begingroup$
It might be more convincing to use integer counting. There are 60 possible outcomes (only one bag out of 60 has drugs). Therefore six tests are needed in the "worst" case, because five tests cannot discriminate 60 possibilities.
$endgroup$
– hardmath
Dec 3 '14 at 3:22
add a comment |
$begingroup$
This kind of problem, "what is the least number of questions I need to ask to solve a problem?", is a topic addressed by information theory. The total information content is
$$
H=1/60log_2(1/60)approx5.9 {rm bits.}
$$
Six bits of information mean we need to ask at least six yes/no questions (six sniffs of the bags) to find the stuff. Thus since it achieves the maximum, your strategy is optimal.
There is some more and a reference in another answer I wrote.
Incidentally I don't think dogs can sniff out 30 bags at once in reality.
$endgroup$
$begingroup$
+1 for the reality comment. The problem as the OP stated is a non-practical one. Similar would be the idea of searching for the one black marble out of a batch of several hundred white marbles. The marbles are in leather pouches and when you look in the pouch you cannot be certain if the black marble is hidden in the bottom of the pouch or not.
$endgroup$
– Michael Karas
May 1 '16 at 11:38
add a comment |
$begingroup$
This kind of problem, "what is the least number of questions I need to ask to solve a problem?", is a topic addressed by information theory. The total information content is
$$
H=1/60log_2(1/60)approx5.9 {rm bits.}
$$
Six bits of information mean we need to ask at least six yes/no questions (six sniffs of the bags) to find the stuff. Thus since it achieves the maximum, your strategy is optimal.
There is some more and a reference in another answer I wrote.
Incidentally I don't think dogs can sniff out 30 bags at once in reality.
$endgroup$
$begingroup$
+1 for the reality comment. The problem as the OP stated is a non-practical one. Similar would be the idea of searching for the one black marble out of a batch of several hundred white marbles. The marbles are in leather pouches and when you look in the pouch you cannot be certain if the black marble is hidden in the bottom of the pouch or not.
$endgroup$
– Michael Karas
May 1 '16 at 11:38
add a comment |
$begingroup$
This kind of problem, "what is the least number of questions I need to ask to solve a problem?", is a topic addressed by information theory. The total information content is
$$
H=1/60log_2(1/60)approx5.9 {rm bits.}
$$
Six bits of information mean we need to ask at least six yes/no questions (six sniffs of the bags) to find the stuff. Thus since it achieves the maximum, your strategy is optimal.
There is some more and a reference in another answer I wrote.
Incidentally I don't think dogs can sniff out 30 bags at once in reality.
$endgroup$
This kind of problem, "what is the least number of questions I need to ask to solve a problem?", is a topic addressed by information theory. The total information content is
$$
H=1/60log_2(1/60)approx5.9 {rm bits.}
$$
Six bits of information mean we need to ask at least six yes/no questions (six sniffs of the bags) to find the stuff. Thus since it achieves the maximum, your strategy is optimal.
There is some more and a reference in another answer I wrote.
Incidentally I don't think dogs can sniff out 30 bags at once in reality.
edited Apr 13 '17 at 12:19
Community♦
1
1
answered Dec 3 '14 at 3:07
Suzu HiroseSuzu Hirose
4,17021228
4,17021228
$begingroup$
+1 for the reality comment. The problem as the OP stated is a non-practical one. Similar would be the idea of searching for the one black marble out of a batch of several hundred white marbles. The marbles are in leather pouches and when you look in the pouch you cannot be certain if the black marble is hidden in the bottom of the pouch or not.
$endgroup$
– Michael Karas
May 1 '16 at 11:38
add a comment |
$begingroup$
+1 for the reality comment. The problem as the OP stated is a non-practical one. Similar would be the idea of searching for the one black marble out of a batch of several hundred white marbles. The marbles are in leather pouches and when you look in the pouch you cannot be certain if the black marble is hidden in the bottom of the pouch or not.
$endgroup$
– Michael Karas
May 1 '16 at 11:38
$begingroup$
+1 for the reality comment. The problem as the OP stated is a non-practical one. Similar would be the idea of searching for the one black marble out of a batch of several hundred white marbles. The marbles are in leather pouches and when you look in the pouch you cannot be certain if the black marble is hidden in the bottom of the pouch or not.
$endgroup$
– Michael Karas
May 1 '16 at 11:38
$begingroup$
+1 for the reality comment. The problem as the OP stated is a non-practical one. Similar would be the idea of searching for the one black marble out of a batch of several hundred white marbles. The marbles are in leather pouches and when you look in the pouch you cannot be certain if the black marble is hidden in the bottom of the pouch or not.
$endgroup$
– Michael Karas
May 1 '16 at 11:38
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1049152%2fhow-can-the-sniffer-dog-find-the-bag-of-drugs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown