Re: [algogeeks] Learn

2010-11-12 Thread sudhir mishra
Write a program to swap odd and even bits in an unsigned integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc). eg[?] input--- 1234567 7654321 888 output-- 411 12109682 948 -- regards *Sudhir Mishra* MNNIT ALLAHABAD --

[algogeeks] Re: Learn

2010-11-12 Thread Dave
For 32-bit integers: result = ((x 0x) 1) | ((x 0x) 1); Dave On Nov 12, 2:12 am, sudhir mishra sudhir08.mis...@gmail.com wrote: Write a program to swap odd and even bits in an unsigned integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2

[algogeeks] Re: Learn

2010-11-12 Thread mohit nagpal
Mask all odd bits with 10101010 in binary (which is 0xAA), then shift them left to put them in the even bits. Then, perform a similar operation for even bits. This takes a total 5 instructions. int swapOddEvenBits(int x) { return ( ((x 0x) 1) | ((x 0x) 1) ); } On Nov 12,

Re: [algogeeks] Learn

2010-11-12 Thread venkatesan B
#includestdio.h int main() { int a,b=0x,c=0x; scanf(%d,a); a=((ab)1)+((ac)1); printf(%d,a); } From: sudhir mishra sudhir08.mis...@gmail.com To: algogeeks@googlegroups.com Sent: Fri, 12 November, 2010 1:42:46 PM Subject: Re: [algogeeks] Learn

Re: [algogeeks] sorting variant

2010-11-12 Thread Algoose chase
I am not sure if this what you are looking for. Assuming that the arrays are sorted in ascending order. Choose one of the 2 arrays as a Reference Array. for each element element in reference array, do a binary search to find all elements that are less than the current element in reference and

Re: [algogeeks] Brain Teaser

2010-11-12 Thread janani thiru
*One possible solution is: |4|6|3|5| |2|8|1|7| *Regards, Janani On Thu, Nov 11, 2010 at 1:26 PM, Amod gam...@gmail.com wrote: We have a rectangle It is divided in eight parts by three vertical and one horizontal line so that there are 8 chambers. Now we have numbers from 1-8 to be filled

Re: [algogeeks] Re: Brain Teaser

2010-11-12 Thread Terence
Good point. Here is one step further: 3. Consider the center 4 numbers(regardless of order): {1,8,a,b}, containing 2 even and 2 odd. and {a,b} can be chosen from {3,4,5,6}. Then there is only one case: {1,8,3,6}. The rest is trivial. On 2010-11-12 13:26, Amod wrote: Let me try to

Re: [algogeeks] Learn

2010-11-12 Thread Terence
(((x 0x)1) | ((x 0x)1)) 5 bit operations in total. On 2010-11-12 16:12, sudhir mishra wrote: Write a program to swap odd and even bits in an unsigned integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc).

Re: [algogeeks] Re: Learn

2010-11-12 Thread MOHIT ....
first do logical AND of 10101010 with number for masking odd bit shift it right 1 times suppose it comes n1 first do logical AND of 01010101 with number for masking even bit shift it left 1 times suppose it come n2 now do n1 || n2 -- You received this message because you are subscribed to

Re: [algogeeks] Re: Learn

2010-11-12 Thread jai gupta
result=((n ((128)/3))1)|((n ((129)/3))1); -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

[algogeeks] servlet object creation

2010-11-12 Thread Ayush Mittal
can anyone explain me how exactly servlet object is created -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to