char A[] = { 1,2,3,4,5 };
int algo(int b, int i) {
if(i == sizeof(A)) { return 1; }
int c = A[i];
int f = algo(b*c, i+1);
A[i] = b*f;
return f*c;
}
On Thu, Sep 29, 2011 at 8:26 AM, raju <[email protected]> wrote:
> Given an integer array. { 1,2,3,4,5 }
> Compute array containing elements
> 120,60,40,30,24 (2*3*4*5,1*3*4*5, 1*2*4*5, 1*2*3*5, 1*2*3*4)
> We shouldn't use division operator( / )
> Time complexity O(n) .. Space complexity O(1)
>
> ~raju
>
> --
> 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.
>
--
Hatta
--
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.