@Kumar: 1<<i is 1 shifted left i places, so anding it with n will give
you the ith bit of n. Similarly for j. Zero out the ith and jth bits
from n. Then shift the ith bit to the jth spot and vice versa and or
them in.

Dave

On Sep 13, 2:31 pm, kumar raja <rajkumar.cs...@gmail.com> wrote:
> @Dave and Gene
>
> I am totally awkward at ur solutions ...How did u develop these solutions??
> . Can u please quote some material/book on this topic..
>
> On 13 September 2011 12:18, Sandy <sandy.wad...@gmail.com> wrote:
>
>
>
>
>
> > @Ankit.
>
> > n=0000 1101
>
> > i=2 j=3
>
> > x = (2^j + 2^i) = 0000 1100
> > x^n = 0000 0001
>
> > Answer should be 0000 1101.
>
> > On Wed, Sep 14, 2011 at 12:39 AM, Ankit Agarwal 
> > <ankuagarw...@gmail.com>wrote:
>
> >> 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.
>
> > --
>
> > *Sandeep Kumar,*
> >  ( Mobile +91-9866507368
>
> > *“I believe in smart work, Believe Me”*
>
> >  --
> > 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
> Kumar Raja
> M.Tech(SIT)
> IIT Kharagpur,
> 10it60...@iitkgp.ac.in
> 7797137043.
> 09491690115.- Hide quoted text -
>
> - Show quoted text -

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