For a basic version (i.e., maximizing the number of base-pairs) of the RNA secondary structure prediction problem and the construction of a parse tree for a stochastic context-free language, O(n(3)) time algorithms were known. For both problems, this paper shows slightly improved O(n(3)(loglog n)(1/2)/(log n)(1/2)) time exact algorithms, which are obtained by combining Valiant's algorithm for context-free recognition with fast funny matrix multiplication. Moreover, this paper shows an O(n(2.776) + (1/epsilon)(O(1))) time approximation algorithm for the former problem and an O(n(2.976) log n + (1/epsilon)(O(1))) time approximation algorithm for the latter problem, each of which has a guaranteed approximation ratio 1 - epsilon for any positive constant epsilon, where the absolute value of the logarithm of the probability is considered as an objective value in the latter problem. The former algorithm is obtained from a non-trivial modification of the well-known O(n(3)) time dynamic programming algorithm, and the latter algorithm is obtained by combining Valiant's algorithm with approximate funny matrix multiplication. Several related results are shown too.