[algogeeks] Knapsack Problem Solved Row-by-Row

2007-04-26 Thread Bootlegger
If I have the following dynamic programming psudo-code for the Knapsack problem: for w = 0 to W do V[0][w] = 0 for w = 0 to W do begin for k = 1 to n do begin if (w < w(k)) then V[k][w] = V[k - 1][w] else V[k][w] = max(V[k - 1][w],V[k -

[algogeeks] Re: Maximum Product contiguous subarray

2007-04-25 Thread Bootlegger
Aye its not the same, I suspect the answer will have something to do with verifying the number of negative numbers in the subarray, seen as a even number of negative numbers will produce a positive product and an odd number of negatives will produce a negative product. Bootlegger On 25 Apr, 13

[algogeeks] Maximum Product contiguous subarray

2007-04-25 Thread Bootlegger
We've all seen the maximum sum contiguous subarray problem, but heres a new take on it: maximum PRODUCT contiguous subarray: Suppowe we have an array A[1 to n] of n integers (positive and negative), Find the maximum product found in any contiguous subarray and produce the pseudo-code for in. I'v

[algogeeks] Maximum Product Contiguous Subarray

2007-04-25 Thread Bootlegger
We've all seen the maximum sum contiguous subarray problem, but heres a new take on it: Say we are given an array A[1 to n] of n inte-gers (positive and negative), we need to find the maximum product found in any contiguous sub-array. I've had a crack at this and im struggling apparently it can