The {\it matrix-chain multiplication} problem is a classic problem that is widely taught to illustrate dynamic programming. The textbook solution runs in $\theta(n^3)$ time. However, there is a complex $O(n \log n)$-time method \cite{HU82}, based on triangulating convex polygons, and a description without proofs or implementation detail, of a much simpler $O(n^2)$-time method \cite{YAO82}. There is also a linear-time approximation algorithm with a small worst-case error bound \cite{HU-SHING1981}. In this paper, we make five contributions both to theory and pedagogy: 1) We simplify the approach in \cite{YAO82}, and provide complete, correct proofs and implementation details, to establish the $O(n^2)$-time bound. We believe that this exposition is simple enough for classroom use. 2) We extend the $O(n^2)$-time bound to a natural class of polygon-triangulation problems that generalizes the original polygon-triangulation problem in \cite{HU82}. 3) We show that the worst-case running time of the method in \cite{YAO82}, and of our version, is $\Theta(n^2)$. 4) We show that in a natural variant of the original polygon-triangulation problem, the approximation method of \cite{HU-SHING1981} 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 $\Theta(n \log n)$ time, while the approach in \cite{YAO82} empirically takes $\Theta(n^2)$ time. Software for these tests is posted on the web.
翻译:{it 矩阵链乘数} 问题是一个经典问题, 被广泛教给用于演示动态编程。 教科书解决方案以$\theta( n3) 3美元时间运行。 但是, 本文中存在一个复杂的 $O (n\ log n) 和时间法\ cite{ hU82}, 依据是三角形的 convex 多边形, 并且没有证明或执行细节的描述, 是一个简单得多的 $O (n2) 美元- 时间法\ cite {YAO82} 。 还有一条线性近似算算法, 有小的 最坏的错误 $( cite{ HU- SING) 。 在本文中, 我们对理论和教程的方法简化了五种方法, 我们的原始时间法显示的是 。