@Hary: thanks, ur code works. Could someone tell me the complexity of the above mentioned code??? heres the working version of the same http://ideone.com/fDTfj Its increasing exponentially.. so can we say log_2(n)???
On Jul 18, 1:57 am, Dumanshu <[email protected]> wrote: > are u sure that this code works??? because last time i checked it > didn't. > > On Jul 18, 1:22 am, hary rathor <[email protected]> wrote: > > ary: > > > > > > > int dividend,divisor,remainder; > > int division(int p,int q){ > > int quotient=1; > > /*if divisor and diviend are equal then quotient=1*/ > > if(p==q){ > > remainder=0; > > return 1;} > > > /*if dividend is smaller than divisor then remainder=dividend*/ > > if(p<q){ > > remainder=p; > > return 0;} > > > /*shift left till divisor > dividend*/ > > while(p>=q){ > > q<<=1; > > quotient<<=1;} > > > /*shift right for one time so that divisor become smaller than dividend*/ > > q>>=1; > > quotient>>=1; > > /*again call division recurcively*/ > > quotient+=division(p-q,divisor); > > return quotient; > > > } > > > int * demo() > > { > > int i; > > long long long long long int multi=1; > > for(i=0;i<a.len;i++) > > { > > multi*=a[i]; > > > } > > > for(i=0;i<a.len;i++) > > { > > out[i]=mul[i]/a[i]; > > > } > > }- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
