Describe the standard O(n^3) time dynamic programming algorithms for solving the matrix chain problem. You should describe all the necessary terms, derive a recurrence relation, and then outline the algorithm and its time complexity.
Describe the standard O(n^3) time dynamic
Dynamic programming: Matrix Chain Multiplication
Description In this assignment you are asked to implement a dynamic programming algorithm for the matrix chain multiplication problem , the goal is to find the most computationally efficient matrix order when multiplying an arbitrary number of matrices. in a row. you can assume that the entire input will be given as integers that can be stored using the standard C++ int type and that matrix sizes will be at least 1.
Input The input has the following format. The first number, n1, in the test case will tell you how many matrices are in the sequence. The first number will be then followed by n+1 is enough to fully specify the dimensions of the multiplied.
Output First you need to output the minimum number of scalar multiplication needed to multiply the given matrices. Then, print the matrix multiplication sequence, via parentheses, that minimizes the total number of number multiplication.
Each matrix should be named A#, where # is the matrix number starting at 0 (zero) and ending at n-1. see the examples below.
Examples of input and output:
2
2 3 5
30
(A0A1)
3
10 10)A2)
6
30 35 10 5 50
7500
((A0A1)A2)
3
10 30 5 60
4500
((A0A15 5 10 20 25
15125
((A0(A1A2))((A3A4)A5))
Recurrence relation:
A recurrence relation is an equation that uses recursion to relate terms in a sequence or elements in an array. It is a way to define a sequence or array in terms of itself. Recurrence relation have application in many areas of mathematics:
Sometimes, a recurrence relation can be "solved" by defining the terms of a sequence in terms of its index rather than previous terms in the sequence. This given a closed form expression for each term in the sequence and eliminates the need for an iterative process to solve for terms in the sequence. there are several ways to accomplish this:
Solving linear recurrence relations
solving recurrence relations with generating functions
solving recurrence relation with the substitution method
solving recurrence relation with the method of summation factors.
Even if the solution of this form is not possible, a recurrence relation is still useful, as it can use to develop computer algorithms. When terms in a sequence are stored, dynamic programming allows one to compute new terms in a sequence efficiently. Recurrence relation is also applicable for recursive backtracking, in which recursion is used to optimize algorithms.
Step by step
Solved in 3 steps