Definition · A bracketing, as a binary treeA bracketing of matrices 1 through n is a binary tree whose leaves are the matrices in order and whose internal nodes are multiplications. Its cost is the sum, over internal nodes, of p·q·r where the left child spans dimensions p by q and the right child q by r.
Theorem · The number of bracketingsThe number of bracketings of n matrices is the Catalan number C(n−1), where C(0) = 1 and C(m) = sum over i of C(i)·C(m−1−i) for i from 0 to m−1.
A bracketing of n ≥ 2 matrices has a last multiplication, splitting the chain after matrix k for some k from 1 to n−1. The left part is a bracketing of k matrices and the right part a bracketing of n−k, and the two are chosen independently, so the count for n is the sum over k of the count for k times the count for n−k.
Writing c(n) for the count, that is c(n) = sum over k of c(k)·c(n−k) with c(1) = 1, which is the Catalan recurrence shifted by one. Hence c(n) = C(n−1), giving 5 at four matrices, 42 at six and 132 at seven — and the lab's enumeration returns exactly those counts, because it is the same recursion with the trees kept instead of counted.
□
The split in that proof is the same split the recurrence minimises over. That is not a coincidence: the recurrence is the enumeration with the sub-answers reused instead of rebuilt, which is what dynamic programming is. The table's Θ(n³) and the enumeration's Catalan(n−1) are two costs for the same search, differing only in whether the sub-results are stored.
Following the pointers back
The reconstruction starts at the cell covering the whole chain and reads its recorded split k. That gives two intervals, i to k and k+1 to j, each of which has its own recorded split, and the recursion bottoms out at single matrices. On the lab's seven-matrix chain the result is ((A1A2)(((A3A4)(A5A6))A7)), which is a bracketing of seven matrices in the given order, as it has to be.
Example · Two claims, checked separatelyThe table reports 2052 after filling 28 cells. The enumeration walks all 132 bracketings with no table at all and reports a best of 2052 and a worst of 14 060. The reconstruction returns the tree above, and re-costing that tree from 5 10 3 12 5 50 6 4 gives 2052. Three numbers, three routes, one answer — and the third route is the only one that says anything about the tree.
Why insist on the third route? Because a reconstruction that follows the wrong pointer returns a bracketing, not an error. It is still a binary tree over the matrices in order; it is still printable; it still looks like an answer. The only cheap way to catch it is to cost it independently and compare with the number the table reported, which is what the panel's re-cost row does.
What the two counts say about each other
On this chain the table fills 28 cells and the enumeration walks 132 bracketings, so the table is ahead by a factor of about five. At four matrices the table fills 10 cells against 5 bracketings and the table is behind. The crossing is early here, which is why matrix chain is the friendly case, and the next course on this path has a problem where the crossing does not arrive until ten items.
Both numbers on the panel are measured on the chain on screen. The proved statements are Θ(n³) against Catalan(n−1), and Catalan grows like 4^n over n to the three halves, so the ratio widens without bound. Neither of those growth claims is established by the two counts, and the counts are what tell you that on four matrices the asymptotically better method is the slower one.
One more thing the enumeration buys: the worst bracketing. On this chain it costs 14 060 against the optimum's 2052, a factor of about 6.9. The table cannot tell you that, because it only ever keeps minima, and a reader who wants to know what the optimisation is worth has to ask the enumeration while the enumeration is still affordable.