Allright, I'm hoping someone can explain this to me. I'm studying for finals and I can't quite figure something out.
The problem is dynamic programming; constructing an optimal binary search tree (OBST). I understand dynamic programming in general and the concepts of this problem in particular, but I don't understand the recursive form of this problem.
I get that we're constructing optimal binary search trees for an increasing subset of these nodes and keeping the answers in a table as we go along to avoid recalculation. I also get that when you root the tree at a_{k}, all of the successful nodes from a_{1} through a_{k-1} along with their corresponding fictitious unsuccessful nodes (i.e. the leaves of the tree) are in the left subtree, and then the ones in the right subtree are a_{k+1} through a_{n}.
Here's the recursive form of the equation that I don't understand:
c(i, j) = min (i < k <= j) {c(i, k-1) + c(k, j) + p(k) + w(i, k-1) + w(k +j)}
where w(i, j) = q(i) + sum from i+1 to j (q(l) + p(l)).
So in c(i,j), from left to right, we have the cost of left subtree + cost of right subtree + probability of successful search for root + w(i, k-1) + w(k +j).
My confusion is how c(i, k-1) differs from w(i, k-1).
The text is Computer Algorithms by Horowitz, Sahni, and Rajasekeran but I've also read CLRS on OBSTs and searched online, and nothing I've come across does a good job of explaining the difference between those parts of the equation.