The matrix-chain multiplication problem is a classic problem that is widely taught to illustrate dynamic programming. The textbook solution runs in θ(n) time. However, there is a complex O(n logn)-time method [3], based on triangulating convex polygons, and a description without proofs or implementation detail, of a much simpler O(n)-time method [9]. There is also a linear-time approximation algorithm with a small worst-case error bound [2]. In this paper, we make five contributions both to theory and pedagogy: 1) We simplify the approach in [9], and provide complete, correct proofs and implementation details, to establish the O(n)-time bound. We believe that this exposition is simple enough for classroom use. 2) We extend the O(n)-time bound to a natural class of polygon-triangulation problems that generalizes the original polygon-triangulation problem in [3]. 3) We show that the worst-case running time of the method in [9], and of our version, is Θ(n). 4) We show that in a natural variant of the original polygon-triangulation problem, the approximation method of [2] does not achieve the same error bound, but does achieve an error bound about twice the original bound. 5)We detail empirical testing, showing that on random data our variant runs in Θ(n logn) time, while the approach in [9] empirically takes Θ(n) time. Software for these tests is posted on the web.
[1]
Prakesh Ramanan.
An Efficient Parallel Algorithm for the Martix-Chain-Product Problem
,
1996,
SIAM J. Comput..
[2]
Man-tak Shing,et al.
An O(n) Algorithm to Find a Near-Optimum Partition of a Convex Polygon
,
1981,
J. Algorithms.
[3]
Oded Schwartz,et al.
Revisiting "Computation of Matrix Chain Products"
,
2019,
SIAM J. Comput..
[4]
Xin-She Yang,et al.
Introduction to Algorithms
,
2021,
Nature-Inspired Optimization Algorithms.
[5]
Man-Tak Shing,et al.
Computation of Matrix Chain Products. Part II
,
1984,
SIAM J. Comput..
[6]
Prakash V. Ramanan.
A new lower bound technique and its application: tight lower bound for a polygon triangulation problem
,
1991,
SODA '91.
[7]
T. C. Hu,et al.
Computation of Matrix Chain Products. Part I
,
1982,
SIAM J. Comput..
[8]
Ronald L. Rivest,et al.
Introduction to Algorithms, 3rd Edition
,
2009
.