Given two integers A B. Determine how many bits required to convert A to
B. Write a function int BitSwapReqd(int A, int B);
--
Nikhil Gupta
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
C= A^B then count number of bits set in C.
On Sun, Jul 31, 2011 at 5:52 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:
Given two integers A B. Determine how many bits required to convert A to
B. Write a function int BitSwapReqd(int A, int B);
--
Nikhil Gupta
--
You received this
int BitSwap(int A,int B)
{
int num=A^B;
int count=0;
while(num!=0)
{
num=num(num-1);
count++;
}
return count;
}
this will run in O(m) where m is no. of ON bits (1's).
is there any other optimal solution for finding no. of 1's in a number?
On Sun, Jul 31, 2011 at
can any one please explain me the question clearly with an examplei'm
not geting it!
thanx in advance!
--
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
compare bits of the number one by one and and count how many are different
print the count..
correct if i am wrong !!
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Sun, Jul 31, 2011 at 6:29 PM, Surya Prakash suryaprakash...@gmail.comwrote:
can
we can just apply xor operation rightit's more easier!!
--
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
@Surya, ^ operator mean XOR operation.
On Sun, Jul 31, 2011 at 6:41 PM, Surya Prakash suryaprakash...@gmail.comwrote:
we can just apply xor operation rightit's more easier!!
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
yupxor would do the required task eaisly !!
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Sun, Jul 31, 2011 at 6:42 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:
@Surya, ^ operator mean XOR operation.
On Sun, Jul 31, 2011 at 6:41 PM, Surya
@what kind of operations can be applied to 'A'?
On Sun, Jul 31, 2011 at 6:54 PM, Amol Sharma amolsharm...@gmail.com wrote:
yupxor would do the required task eaisly !!
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Sun, Jul 31, 2011 at 6:42
@Kamakshi : any kind of operation can be used ..
Exactly XORing the bits should do the trick .. and we can then count the
number of 1s in the answer to know how many bits are different .
This is like the Hamming distance used in Hamming code in Networks .
On Sun, Jul 31, 2011 at 8:37 AM,
10 matches
Mail list logo