Well I think they asked not to use division operator with purpose.What if the original element contains a 0?
On Mon, Jul 18, 2011 at 6:15 AM, Dumanshu <duman...@gmail.com> wrote: > @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 <duman...@gmail.com> wrote: > > are u sure that this code works??? because last time i checked it > > didn't. > > > > On Jul 18, 1:22 am, hary rathor <harry.rat...@gmail.com> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.