We define an on-line problem to be a problem where each input is available only after certain outputs have been calculated. The usual kind of problem, where all inputs are available at all times, is referred to as an off-line problem. We present an efficient algorithm for the on-line two dimensional dynamic programming problem that is used for the prediction of RNA secondary structure. Our algorithm uses as a module an algorithm for solving the on-line one dimensional dynamic programming problem. The time complexity of our algorithm is n times the complexity of the online one dimensional dynamic programming problem. For the concave case, we present a linear time algorithm for the on-line one dimensional problem. This yields an optimal O(n2) time algorithm for the on-line two dimensional concave problem. The constants in the time complexity of this algorithm are fairly small, which make it practical. For the convex case, we use an O(nα(n)) time algorithm for the on-line one dimensional problem, where α(.) is the functional inverse of Ackermann's function. This yields an O(n2α(n)) time algorithm for the on-line two dimensional convex problem. Both algorithms improve on previously known algorithms.