The Missing File
You are an FBI analyst tasked with auditing case files. You have a list of 100 case files, each with a unique ID from 1 to 100. Each file should have a corresponding digital record. You are told that exactly one file is missing its digital record, but you don't know which. You have access to a database that can answer queries of the form: 'Does the set of files with IDs in the range [a, b] all have digital records?' The database returns 'yes' if all files in that range have records, and 'no' otherwise. You can make at most 7 queries. How can you identify the missing file?
1. Describe a strategy using at most 7 queries to find the missing file ID. Show the sequence of queries and how you narrow down the answer.
Read the worked answer
This is a binary search problem. Since exactly one file is missing, we can use binary search to find it. The range of IDs is 1-100. At each step, we query a subrange to see if it contains the missing file. If the query returns 'no', the missing file is in that subrange; if 'yes', it's in the complement. But note: the query asks if all files in [a,b] have records. If 'no', then at least one is missing in that range. Since only one is missing overall, 'no' means the missing file is in [a,b]. 'Yes' means the missing file is not in [a,b]. We can binary search on the ID space. Start with low=1, high=100. Query [low, mid]. If 'no', high=mid; else low=mid+1. Repeat until low=high. Number of queries: ceil(log2(100)) = 7. So 7 queries suffice. Example: Query [1,50]. If no, missing in 1-50; else in 51-100. Then query [1,25] or [51,75], etc. After 7 queries, we pinpoint the ID.
2. Suppose the database has a flaw: it sometimes returns 'yes' incorrectly (false positive) with probability 0.1, but never returns 'no' incorrectly. How does this affect your strategy? Can you still guarantee finding the missing file with 7 queries? If not, what is the minimum number of queries needed to be 99% confident?
Read the worked answer
With false positives, a 'yes' answer is not fully reliable; it might be wrong. A 'no' answer is reliable (since no false negatives). So if we get a 'no', we can trust that the missing file is in the queried range. If we get 'yes', the missing file could still be in the range (if false positive occurred) or not. This complicates binary search because a 'yes' might mislead us. To guarantee finding the missing file, we cannot rely on 'yes' answers. However, we can design queries to avoid ambiguity by using 'no' answers. But we cannot force a 'no' unless the range contains the missing file. Since we don't know where it is, we might get false positives. One approach: use a strategy that only relies on 'no' answers. For example, query individual files? That would take up to 100 queries. Not good. Alternatively, we can use repetition or group testing. With 7 queries, we cannot guarantee because false positives could cause us to eliminate the correct half. For instance, if we query [1,50] and get 'yes' (false positive), we would think missing is in 51-100, but it's actually in 1-50. Then we would never find it. So 7 queries do not guarantee. To be 99% confident, we need to account for false positives. We can use a strategy that repeats queries or uses redundancy. One method: use a binary search but when we get 'yes', we can't be sure. We could query the complement as well? But that uses more queries. A simpler approach: since false positive rate is 0.1, if we query a range and get 'yes', the probability it's a false positive is 0.1 (if missing is in range) or 0 (if missing not in range). Actually, if missing is not in range, the database always returns 'yes' correctly. So a 'yes' is only suspicious if the missing file is actually in the range. But we don't know. To be 99% confident, we can use a strategy that repeats the binary search multiple times or uses a different split. However, with 7 queries, we have limited room. Maybe we can use a non-adaptive group testing approach. But given the constraint, perhaps the answer is that 7 queries are not enough; we need more. The minimum number of queries to be 99% confident might be higher. But the problem asks: 'Can you still guarantee finding the missing file with 7 queries?' Answer: No. 'If not, what is the minimum number of queries needed to be 99% confident?' This is complex. Perhaps we can use a strategy that queries overlapping ranges to detect false positives. For example, query [1,50] and [1,25] and [26,50] etc. But we need to compute. Given the time, I'll state that 7 queries cannot guarantee; to be 99% confident, one could use a strategy that repeats the binary search with different splits, but a precise minimum is difficult. A conservative answer: use 14 queries (repeat each query twice) to reduce false positive probability to 0.01 per query, but that's not exactly 99% overall. Alternatively, use a method that identifies the missing file by querying individual files in a binary code. Since there are 100 possibilities, we need log2(100) ≈ 7 bits of information. But with noise, we need error-correcting codes. A simple repetition code: each bit queried 3 times majority vote gives error probability ~0.028, not 99%. To get 99% confidence, we need more. I'll say at least 10 queries might be needed, but without exact calculation, I'll note that 7 is insufficient and suggest a strategy like querying each file individually until found, but that's up to 100. So the answer is likely that 7 queries cannot guarantee, and to be 99% confident, one might need around 10-12 queries using a robust binary search with verification. However, I'll provide a reasoned answer: No, 7 queries cannot guarantee. To be 99% confident, use a strategy that, after binary search, verifies the result by querying the identified file individually (but that adds one query). Still, false positives during binary search could mislead. A better approach: use a binary search but whenever you get a 'yes', query the same range again; if both 'yes', assume true with probability 0.99 (since false positive twice is 0.01). That would require up to 14 queries in worst case. So minimum queries for 99% confidence might be 14. I'll go with that.