Author: Unknown
Subject: Practice Midterm Answers
Date: Tuesday, 03 Mar 2020, 16:26:27
Hello, I'm wondering if this is a typo on the practice midterm solutions for the dynamic programming approach to finding largest subarray product: "Let P1(K) = largest product in X[0],...,X[K-1]. Let P2(K) = largest product of the form X[I]*...*X[K-1], 0 <= I < K. Set P1(1) = X[0] and P2(1) = X[1]. Set P2(K+1) = max (P1(K)*X[K], X[K]) and P1(K+1) = max {P1(K), P2(K+1) for 1 <= K < N" Shouldn't P2(k+1) be set to max (P2(K)*X[K], X[K]) since P1(K)*X[K] might not be contiguous?PREV INDEX NEXT