palin
DESCRIPTION
java pgmTRANSCRIPT
The idea is simple, we take two pointers one at leftmost bit and another at rightmost bit, extractbits information using the pointers both bits should either be 0 or 1. and move the pointers untilthey meet.Nowhow would you extract the bit is tricky one, basically you first get number of bits in theinteger and then shift 1 left by (number of bits -1 this will become our leftmost pointer andnumber1will beourrightmost pointer.!se"operatorbetweenoriginal numberandthesepointers if the result is 0 then the corresponding bit is #ero else(non-#ero then corresponding bitis 1.Note: check for non-#ero rather then $ 0 as 1000000000000 will be negative.%ere is the &ava code to get the si#e of the integerpublic int getSizeOfInteger(){int size =1;int num =1;//shift the number untill it becomes negative(1 followe b! "#s)while(num $ "){num = num%%1;size&&;'return size;'%ere is the &ava code to get if the bit representation of the number is palindrome or notpublic boolean is(alinrome(int n){int right(ointer =1;int left(ointer = 1%%(getSizeOfInteger())1);int count = getSizeOfInteger()/*;while(count $ "){//+hec,ing if both bits are " or both are non)zero an then negateif( -(((n . left(ointer) -= " .. (n . right(ointer) -= ") //( (n . left(ointer) == " .. (n . right(ointer) == "))){return false;//0oth bits are not same'count));'return true;'