Suppose that $n$ matrices have dimensions $1 \times 1, 1 \times d, d \times 1, or \space d \times d$. Design an algorithm to find the optimal order to multiply them.
My approach is to minimize the dimension of resulting matrix. for example, $d \times d$ matrix times another $d \times d$ matrix will have an $O(n^3)$. Therefore, if there's a $d \times d$ matrix, always multiplies it with a $d \times 1$ or $1 \times d$ matrix. If there are pairs of $1 \times d$ and $d \times 1$, make them multiply.
Is it my approach practicable?
This is a classic problem with introduction to dynamic programming. Corn, Leicerson and Rivest analyze this in depth in Section 15.2.