3-PARTITION problem

后端 未结 6 2021
醉酒成梦
醉酒成梦 2020-12-05 05:56

here is another dynamic programming question (Vazirani ch6)

Consider the following 3-PARTITION problem. Given integers a1...an, we want to determine whet

6条回答
  •  天涯浪人
    2020-12-05 06:36

    Let's say you want to partition the set $X = {x_1, ..., x_n}$ in $k$ partitions. Create a $ n \times k $ table. Assume the cost $M[i,j]$ be the maximum sum of $i$ elements in $j$ partitions. Just recursively use the following optimality criterion to fill it:

    M[n,k] = min_{i\leq n}  max ( M[i, k-1], \sum_{j=i+1}^{n} x_i ) 
    
    Using these initial values for the table: 
    
    M[i,1] = \sum_{j=1}^{i} x_i  and  M[1,j] = x_j  
    
    The running time is $O(kn^2)$ (polynomial )
    

提交回复
热议问题