one question though?
why do you prefer division by bit operations, when there is / operator
( 32 bit div operation is inbuilt in almost all the processors so it
can be done in constant time)
also you recursion is not Tail-recursive so stack will grow like
crazy!!
On Oct 10, 9:36 pm, harit agarwa
@Debanjan
really nice solution
--~--~-~--~~~---~--~~
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
On Oct 10, 9:12 pm, Ramaswamy R wrote:
> Two passes. Initialize the result array with all 1's.
> Pass 1: Maintain the product until i-1 when processing element at i. The
> product would be 1 for the 0th element. For every i'th element of the result
> array, multiply it with the product (till th
traverse the array once and ge product of all elements , this is dividend
now again traverse for each a[i] do division(divisor,a[i])
code for division without using /
#include
int dividend, divisor, remainder;
/* Division function Computes the quotient and remainder of two numbers
using bit shifti
Nice solution Ramaswamy...
--~--~-~--~~~---~--~~
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
algoge
Two passes. Initialize the result array with all 1's.
Pass 1: Maintain the product until i-1 when processing element at i. The
product would be 1 for the 0th element. For every i'th element of the result
array, multiply it with the product (till the previous element).
Pass 2: Do the same but in th