Puzzle | Data Recovery Problem

Suppose you have three pen drives P1, P2 and P3 each having 1GB capacity. You have also 3GB data. You have to divide these data into P1, P2 and P3 such that if any one of the pen drive among P1, P2, P3 got crashed than you should be able to recover all the data from remaining two pen drives.

For example – if P1 is crashed then you should be able to recover 3GB data from P2 and P3.
Similarly in the case of P2 and P3.

Answer :

Suppose the 3GB data is divided into three groups A, B and C. Then the distribution would be like this
P1-> A^B
P2-> B^C
P3-> C^A

Now suppose pen drive P3 is lost and we are left with data of P1 and P2. As we know that
P1 contains data which is xor of A and B.
P2 contains data which is xor of B and C.



We can perform below steps to recover the whole data.

Step 1 : XOR of P1 and P2 gives (A^B)^(B^C) = B
Step 2 : XOR of this B which is obtained from step 1 with P1 gives (A^B)^B = A
Step 3 : XOR of this B which is obtained form step 1 with P2 gives (B^C)^C = C.

Performing the above-mentioned steps will give the data A, B, and C.

Similarly, we can perform these steps in the case of P1 and P2.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


9


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.