It is essentially the same as the dynamic programming matrix used for sequence comparison. However, the sequence is compared to itself, and for two symbols to match (usually, A matches A, G matches G,...), they must be complementary. That is, A <--> U and G <--> C.
Therefore, folding of the sequence can be predicted in time. Click here for a small set of informative slides.