Suppose you want to find out what the missing number in the list [1 .. 5]:
1 = 001
2 = 010
3 = 011
4 = 100
5 = 101
XOR = 001
If the number 4 is missing:
XOR = 001
1 = 001
2 = 010
3 = 011
5 = 101
XOR = 100
You can see that the method works by properties of the XOR (you can see it?)
.
The same is true when only a number is doubled (Right?).
Wladimir Araujo Tavares
*Federal University of Ceará
*
On Fri, Jun 10, 2011 at 5:13 PM, Dumanshu <[email protected]> wrote:
> @kunal... yeah it will work. thnx :)
>
> On Jun 10, 11:41 pm, Kunal Patil <[email protected]> wrote:
> > @ Dumanshu:
> > With memory restriction also XOR method works.. :)
> > In this case difference is just that you will be working with
> 40000000000/ X
> > number of files..where X is size of the RAM...just maintain a variable
> > Curr_XOR_value and go on XORing it with element read from the file.
> > When you are done with reading all those numbers from "40000000000/ X"
> > files..
> > (Curr_XOR_value) * XOR* (expected_XOR_value for 1 to 40000000000) ...
> > will give missing number...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.