Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
Can anybdy sum up, wats the best approach and under what cicumstances ?? -- 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

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread shady
@dave no doubt division is costly, but will time complexity change in your case ? On Sat, Sep 10, 2011 at 10:25 PM, Neha Singh wrote: > the time complexity of my approach : O(a*b)^2 > and of the other approach, i guess : O(a) , where a is the larger no. > correct me if i m wrong > > So, complexi

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
the time complexity of my approach : O(a*b)^2 and of the other approach, i guess : O(a) , where a is the larger no. correct me if i m wrong So, complexity wise my approach does not seem to be gud -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gro

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread shady
yup, yours(binary gcd) is better. On Sat, Sep 10, 2011 at 9:34 PM, Neha Singh wrote: > How abt dis : > > The algorithm reduces the problem of finding the GCD by repeatedly applying > these identities: > 1. gcd(0, v) = v, because everything divides zero, and v is the largest > number that divides

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
How abt dis : The algorithm reduces the problem of finding the GCD by repeatedly applying these identities: 1. gcd(0, v) = v, because everything divides zero, and v is the largest number that divides v. Similarly, gcd(u, 0) = u. gcd(0, 0) is not typically defined, but it is convenient to set gcd(0

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread sukran dhawan
while(num2 != 0) { rem = num1 % num2 num1 = num2 num2 = rem } On Sat, Sep 10, 2011 at 8:59 PM, Gaurav Menghani wrote: > C'mon > > http://en.wikipedia.org/wiki/Greatest_common_divisor > > On Sat, Sep 10, 2011 at 11:24 AM, Neha Singh > wrote: > > > > -- > > You received this message because you

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Gaurav Menghani
C'mon http://en.wikipedia.org/wiki/Greatest_common_divisor On Sat, Sep 10, 2011 at 11:24 AM, Neha Singh wrote: > > -- > 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 uns

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread amrit harry
Euclid's GCD Algorithm: http://www.cs.berkeley.edu/~vazirani/s99cs170/notes/lec3.pdf On Sat, Sep 10, 2011 at 8:54 PM, Neha Singh wrote: > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@g

[algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
-- 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 ht