Similary as we  are counting set bits count 0's nd cmpare nd set 1 if
coutn(1)>count(0) for each integer in array

On Sun, Aug 21, 2011 at 1:44 PM, Sanjay Rajpal <srn...@gmail.com> wrote:

> @Dheeraj : I think u should review the problem again.
> What u have posted is a way to find no. of set bits in a number.
> But problem is check a bit at a position in all number for no. of 1s and
> 0s, not in a single number.
> This has to be done for all 32 bits.
>
> Sanju
> :)
>
>
>
> On Sun, Aug 21, 2011 at 1:11 AM, Dheeraj Sharma <
> dheerajsharma1...@gmail.com> wrote:
>
>> while(a)
>> (
>> a&=(a-1)
>> count++
>> )
>> counts number of 1s in number 'a'..
>> Loop can be breaken if count exceeds 16..
>>
>> On 8/21/11, himanshu kansal <himanshukansal...@gmail.com> wrote:
>> > problem: There is an array containing integers.....
>> > for every bit in the integer,you have to print a 1 if no of 1s
>> > corresponding to that bit is more than no of 0s corresponding to that
>> > bit (counting that bit in all the integers) otherwise print a 0(if no
>> > of 0s corresponding to that bit are more).
>> >
>> > this you have to do for all bits in the integers.....
>> >
>> > assumption:integers are of 32bits.
>> > no of integers in array are odd...(i.e. there is no case like no. of
>> > 1s=no. of 0s)
>> >
>> > i have  done this by counting the no of 1s and 0s for all bits.....
>> >
>> > but can anyone suggest any other efficient approach (somewhat using
>> > bitwise operators).....
>> >
>> > --
>> > 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?hl=en.
>> >
>> >
>>
>>
>> --
>> *Dheeraj Sharma*
>> Comp Engg.
>> NIT Kurukshetra
>> +91 8950264227
>>
>> --
>> 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?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 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?hl=en.
>



-- 
With regards
  ............
Puneet

-- 
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?hl=en.

Reply via email to