[algogeeks] Re: addition without using arithmetic operators

2009-09-07 Thread Gokul
you can try this.. int add(int x, int y) { if (!x) return y; else return add((x & y) << 1, x ^ y); } On Sep 7, 4:01 pm, ritter wrote: > how to add two integers without using arithmetic operators? > can anyone help me. --~--~--

[algogeeks] swap every two bits in the byte..

2009-09-05 Thread Gokul
how ll u swap every two bits in the a byte??? can anyone help me??? for eg. consider a byte as input... 10111010 output should be 01110101 it exactly swap the two bits(no complement is takesplace here).. --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] Find details of all programming language concepts from cobol to Java and many more.

2008-04-24 Thread gokul
Find details related to C/C++ programming languages. From preparing flowchart and many more. A one stop website for all your programming language needs http://www.blogonprogramming.blogspot.com http://www.sqlserversoftware.blogspot.com --~--~-~--~~~---~--~~ You re

[algogeeks] A one shop website for all your programming language needs

2008-04-13 Thread gokul
A one shop website for all your IT needs. Find details regarding programing languages such as C/C++ and .Net. http://www.blogonprogramming.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks

[algogeeks] Re: Need an algorithm to find the missing numbers.

2006-08-29 Thread gokul
kumar wrote: > kerry wrote: > > > need O(n) time > > the array is set[n], > > for(i = 1, i <=n ; i++) > > if((set[i] & 1) & (set[i + 1] & 1)) > > then miss the number i+1; > > ur logic is not satisfied for even the array is in sorted order also. > For sorted array > we need ( set [ i

[algogeeks] Re: Need an algorithm to find the missing numbers.

2006-08-29 Thread gokul
yes, it's likely we think it's sorted since Joe uses the word _sequence_ : "In a sequence o,f from 1 to n (1,2,3,...n) numbers, we need to find the missing numbers. There will not be duplicates." anyway its a better problem if unsorted... --~--~-~--~~~---~--~~ Y

[algogeeks] Re: Try this ..

2006-08-29 Thread gokul
girsh and kamlesh: that may work if the (n-1) numbers are integers 1 to n. What if they can be anything. (from your S(n) = n*(n+1) / 2 ) ) adak : distribution sort - this is effectively the same as the bitmap thing which Lego Haryanto mentioned in the beginning. (we're only using a byte or somethi