Algorithm design and analysis - Matrix continually multiply problems

Problem Description:

Given n matrix {A1, A2, ..., An}, where Ai and Ai + 1 is multiplicative, i = 1,2 ..., n-1. How to determine the order computing the matrix even calculate the product, so that even in this order compute the matrix multiplication product of the minimum number required. For example, given three multiplicative matrix {A1, A2, A3} dimensions are 10 * 5 * 100, 100 and 5 * 50, A3, using the number of multiplications (A1A2) was 10 + 5 * 100 * 10 * 5 * 50 = 7500, while the use of A1 (A2A3), the number of multiplications is 5 * 100 * 100 * 50 + 10 * 50 = 75,000 multiplications, obviously, is the best sequence (A1A2) A3, the number of multiplications to 7500 .

Bracketed way to have a great impact on the calculation of the amount, so naturally raised Optimum Order of Matrix continually multiply, ie, one after another for a given n matrices, how to determine the order of evaluation matrix continually multiply, so this order compute the matrix product of the number of connected by the minimum number required.

problem analysis:

 

 

 Matrix continually multiply the number of Catalan is a common example, calculated on the time complexity of the need to refer to the content of Discrete Mathematics About Catalan.

Here Optimum Order of Matrix solution using dynamic programming even consider the product.

1, analysis of the structure of the optimal solution

 

 

 

 Optimal substructure nature of the problem is a significant feature of the problem can be solved using dynamic programming! ! !

2, the establishment of a recursive relationship

 

 

 

Guess you like

Origin www.cnblogs.com/wkfvawl/p/11564275.html