[algogeeks] Re: find elements in array with odd frequency

2009-08-24 Thread Geoffrey Summerhayes



On Aug 23, 5:00 am, Dufus  wrote:
> Idea is simple either to keep a count and emit elements with odd count
> (frequency) or XOR element with itself for each time it occurs in
> input and then emit elements which have non zero XORed result(which
> basically corresponds to elements with odd frequency).
>
> _dufus
>

Or just use a bit array and XOR the number's position with one, at the
end
the bits that are on have an odd count.

--
Geoff

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: find elements in array with odd frequency

2009-08-24 Thread Nagendra Kumar

Plz write the code here.

On Sun, Aug 23, 2009 at 2:30 PM, Dufus wrote:
>
> Idea is simple either to keep a count and emit elements with odd count
> (frequency) or XOR element with itself for each time it occurs in
> input and then emit elements which have non zero XORed result(which
> basically corresponds to elements with odd frequency).
>
> _dufus
>
>
> On Aug 23, 8:44 am, Nagendra Kumar  wrote:
>> How are u doing with xor. Can u post ur thought here.
>>
>> Thanks
>> Nagendra
>>
>>
>>
>> On Sun, Aug 23, 2009 at 2:07 AM, Dufus wrote:
>>
>> > We can count or XOR but I couldnt find any advantage of XORing except
>> > for preventing overflow.
>>
>> > _dufus
>>
>> > On Aug 22, 5:03 pm, Nagendra Kumar  wrote:
>> >> I think you are trying sorting and then counting the frequency of the 
>> >> numbers.
>>
>> >> -Thanks
>> >> Nagendra
>>
>> >> On Sat, Aug 22, 2009 at 11:21 AM, Dufus wrote:
>>
>> >> > I can think of a naive algorithm which takes O(n) time and O(n) space.
>> >> > or O(nlogn) with O(1) space.
>>
>> >> > May be someone else might come up with a better algo.
>>
>> >> > _dufus
>>
>> >> > On Aug 21, 3:01 pm, nagendra kumar  wrote:
>> >> >> Given an array of integers,Print the integers whose appareance are in
>> >> >> odd times.
>> >> >> Need not worry abt order while printing the output.
>> >> >> Need Algotithm in o(n) time complexity.
>> >> >> Need efficient space complexity.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: find elements in array with odd frequency

2009-08-24 Thread Anil C R
Its straight forward if the range of the array elements is bounded. or you
could hash a number (key) and its frequency (value) in a hash table this
would give you almost O(n) complexity.

On Mon, Aug 24, 2009 at 1:00 PM, Nagendra Kumar wrote:

>
> Plz write the code here.
>
> On Sun, Aug 23, 2009 at 2:30 PM, Dufus wrote:
> >
> > Idea is simple either to keep a count and emit elements with odd count
> > (frequency) or XOR element with itself for each time it occurs in
> > input and then emit elements which have non zero XORed result(which
> > basically corresponds to elements with odd frequency).
> >
> > _dufus
> >
> >
> > On Aug 23, 8:44 am, Nagendra Kumar  wrote:
> >> How are u doing with xor. Can u post ur thought here.
> >>
> >> Thanks
> >> Nagendra
> >>
> >>
> >>
> >> On Sun, Aug 23, 2009 at 2:07 AM, Dufus
> wrote:
> >>
> >> > We can count or XOR but I couldnt find any advantage of XORing except
> >> > for preventing overflow.
> >>
> >> > _dufus
> >>
> >> > On Aug 22, 5:03 pm, Nagendra Kumar  wrote:
> >> >> I think you are trying sorting and then counting the frequency of the
> numbers.
> >>
> >> >> -Thanks
> >> >> Nagendra
> >>
> >> >> On Sat, Aug 22, 2009 at 11:21 AM, Dufus
> wrote:
> >>
> >> >> > I can think of a naive algorithm which takes O(n) time and O(n)
> space.
> >> >> > or O(nlogn) with O(1) space.
> >>
> >> >> > May be someone else might come up with a better algo.
> >>
> >> >> > _dufus
> >>
> >> >> > On Aug 21, 3:01 pm, nagendra kumar  wrote:
> >> >> >> Given an array of integers,Print the integers whose appareance are
> in
> >> >> >> odd times.
> >> >> >> Need not worry abt order while printing the output.
> >> >> >> Need Algotithm in o(n) time complexity.
> >> >> >> Need efficient space complexity.
> >
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Merging companies

2009-08-24 Thread ankur aggarwal
Merging companies
Suppose we have N companies, and we want to eventually merge them into
one big company. How many ways are there to merge?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---