@debajyoti sharma
your method works only if a number is repeated even number of times ...try
for this int array[]={6,3,4,1,4,5,6,1,1,5};... so xor method fails... or can
dere be any modofication in it ??
On Mon, Jun 14, 2010 at 6:18 PM, Debajyoti Sarma
<[email protected]>wrote:
> @jalaj jaiswal
>
> given array contain 3,6 both r unique.
> Is this the exact question?
>
> if array is 6,3,4,1,4,5,6,1,5 than we can solve using xor properties.
>
> int a,b=5;
> a=b^b; //value of a is 0 convert in binery form and do u will get
> a=0^a; //value of a is a itselt
>
> Program:
>
> #include<stdio.h>
> int unique(int array[],int size)
> {
> int i,x=0;
> for(i=0;i<size;i++)
> x^=array[i];
> return x;
> }
> int main()
> {
> int array[]={6,3,4,1,4,5,6,1,5};
> int size=sizeof(array)/sizeof(array[0]);
> printf("%d",unique(array,size));
> }
>
>
> this will give the result bcoz
>
> 0^6^3^4^1^4^5^6^1^5 = 3
> as xor is associative .
>
> On 6/14/10, kunzmilan <[email protected]> wrote:
> > Write the array as a vector string S, eg
> > (1,0,0,0...)
> > (0,0,1,0...)
> > (0,0,0,1...)
> > etc.
> > Find the quadratic form S^T.S. On its diagonal, occurences of all
> > numbers are counted.
> > kunzmilan
> >
> >
> > On 13 čvn, 20:44, jalaj jaiswal <[email protected]> wrote:
> >> give an algo to find a unique number in an array
> >>
> >> for eg a[]={1,3,4,1,4,5,6,1,5}
> >>
> >> here 3 is the unique number as it occur only once... moreover array
> >> contains
> >> only 1 unique number
> >>
> >> --
> >> With Regards,
> >> Jalaj Jaiswal
> >> +919026283397
> >> B.TECH IT
> >> IIIT ALLAHABAD
> >
> > --
> > 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]<algogeeks%[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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
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.