let x = 2^j + 2 ^i
new number after swapping the digits is x XOR n

eg n = 0000 1101
j = 6 i = 2
x = 0100 0100
 new number = x XOR n = 0100 1001


-- 
Ankit Agarwal
Computer Science & Engg.
Integrated Dual Degree, V yr
Department of Electronics & Computer Engineering
Indian Institute of Technology Roorkee
Ph. no. +91-9580098805

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