[algogeeks] Any help on bits?

2011-07-31 Thread Nikhil Gupta
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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread prateek gupta
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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Abhishek Gupta
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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Surya Prakash
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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Amol Sharma
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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Surya Prakash
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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Nikhil Gupta
@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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Amol Sharma
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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Kamakshii Aggarwal
@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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Ankit Minglani
@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,