![]() |
Question: You are in a spaceship with an n-processor computer. Suddenly, the spaceship is hit by an alien laser beam and some of the processors are damaged. However, you recognize that quite half the processors are still good. You can ask one processor whether or not it thinks every other processor is right or horrific. An exact processor will usually inform the truth, however, a horrific one will usually lie. A ‘step’ consists of asking one processor if it thinks another processor is good or bad. Find a minimum number of steps required to find at least one good processor. Solution: Let the processors be numbered 1,2,3….. up to n. Let’s start by asking processor 1 if processor 2 is good. If the answer is “no”, remove these two processors from the list and start again. Remember that you already removed one good processor and one bad processor from the list, so more than half of the remaining processors are still good. But if processor 1 says processor 2 is good, continue by asking processor 2 about processor 3, 3 about 4, and so on, until you get a “no” answer. Let’s suppose, the processor ‘j’ that says processor j+1 is bad. Both processors j and j+1 are removed from the list (as before, more than half of the remaining processors are good, since one of the two which were removed was good and one was bad), and the process is continued by asking processor j-1 about processor j (the processor that was after j+1 before it was removed and the original processor j). |
Reffered: https://www.geeksforgeeks.org
Puzzles |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |