Yes, that's correct what is wrong with that?
Basically when n&1 occurs, it kind of initiates the multiplication by
m by setting m+=1. So,
After that, m gets multiplied by 2 which is nothing but left shift by 1.
n=100
m remains 0
as n&1==0 so m=0;
n-> 10;

2. n=10
m*2-> m=0;
n&1=0 so m=0;
n->1;

3 n=1;
m*2=0;
n&1 so m+1-> m=1;
n->0



On 7/21/11, aditi garg <aditi.garg.6...@gmail.com> wrote:
> No actually its fine if the number is 1100...bt for 0100 it gives only 0001
> bec it only increments it once after shifting thrice and thn it becomes 0000
> and it exits and so m nvr gets multiplied by 2...
>
> On Thu, Jul 21, 2011 at 10:01 PM, archita monga
> <kool.arc...@gmail.com>wrote:
>
>> @aditi-the  algo is giving a problem when the last bit is 0..just like in
>> ur case..when the number is being reversed instead of 0010 it is giving
>> only
>> 10 and neglecting the initial 0's since dey do not contribute in the
>> number..i guess dis is d prob dat u r facing?
>>
>>
>> On Thu, Jul 21, 2011 at 9:57 PM, aditi garg
>> <aditi.garg.6...@gmail.com>wrote:
>>
>>> i have tried solving so many tyms bt i dnt think dis also is wrking fine
>>> fr 0100 input..plz chk
>>>
>>>
>>> On Thu, Jul 21, 2011 at 9:49 PM, aditi garg
>>> <aditi.garg.6...@gmail.com>wrote:
>>>
>>>> @ankit : smhow im not able to follow the steps ur also is taking fr
>>>> input
>>>> 0100 ,tho its fine fr 1011 and im not getting the required ans...can u
>>>> plz
>>>> explain...
>>>>
>>>>
>>>> On Thu, Jul 21, 2011 at 8:31 PM, Aman Goyal
>>>> <aman.goya...@gmail.com>wrote:
>>>>
>>>>> @ankit gupta: superb solutn
>>>>>
>>>>>
>>>>> On Thu, Jul 21, 2011 at 8:09 PM, SkRiPt KiDdIe
>>>>> <anuragmsi...@gmail.com>wrote:
>>>>>
>>>>>> To get complete 32 bit inverse :
>>>>>>
>>>>>>         x=((x>>1)&0x55555555) | ((x<<1)&0xAAAAAAAA);
>>>>>>         x=((x>>2)&0x33333333) | ((x<<2)&0xCCCCCCCC);
>>>>>>         x=((x>>4)&0x0F0F0F0F) | ((x<<4)&0xF0F0F0F0);
>>>>>>         x=((x>>8)&0x00FF00FF) | ((x<<8)&0xFF00FF00);
>>>>>>         x=((x>>16)&0x0000FFFF) | ((x<<16)&0xFFFF0000);
>>>>>>
>>>>>>  --
>>>>>> 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.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Aditi Garg
>>>> Undergraduate Student
>>>> Electronics & Communication Divison
>>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>>>> Sector 3, Dwarka
>>>> New Delhi
>>>>
>>>>  9718388816
>>>>
>>>>
>>>
>>>
>>> --
>>> Aditi Garg
>>> Undergraduate Student
>>> Electronics & Communication Divison
>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>>> Sector 3, Dwarka
>>> New Delhi
>>>
>>>  9718388816
>>>
>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> Archita Monga
>>
>>  --
>> 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.
>>
>
>
>
> --
> Aditi Garg
> Undergraduate Student
> Electronics & Communication Divison
> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> Sector 3, Dwarka
> New Delhi
>
> 9718388816
>
> --
> 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.

Reply via email to