[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 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.



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 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.




-- 
Prateek Gupta
7th sem, Information Technology,
Netaji Subhas Institute Of Technology
Delhi.

-- 
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.



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 5:57 PM, prateek gupta prateek00...@gmail.comwrote:

 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 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.




 --
 Prateek Gupta
 7th sem, Information Technology,
 Netaji Subhas Institute Of Technology
 Delhi.

  --
 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.




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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.



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 this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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 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 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.



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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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 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.




-- 
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT, New Delhi, India

-- 
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.



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 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 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.




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India


  --
 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.



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 PM, Nikhil Gupta 
 nikhilgupta2...@gmail.comwrote:

 @Surya, ^ operator mean XOR operation.


 On Sun, Jul 31, 2011 at 6:41 PM, Surya Prakash suryaprakash...@gmail.com
  wrote:

 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
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India


  --
 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.




-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
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.



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, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:

 @what kind of operations can be applied to 'A'?


 On Sun, Jul 31, 2011 at 6:54 PM, Amol Sharma amolsharm...@gmail.comwrote:

 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 Prakash 
 suryaprakash...@gmail.com wrote:

 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
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India


  --
 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.




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

  --
 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.




-- 
The more you sweat in the field, the less you bleed in war.

Ankit Minglani
NITK Surathkal

-- 
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.