An algorithm for cross-dating tree rings based on dynamic programming is presented. The algorithm considers all possible combinations of missing and double rings while minimizing a squared error loss function in relation to a reference chronology. There is a provision for the user to increase the penalty associated with inserting missing or double rings. Therefore, the algorithm is not totally objective and depends on informed user interaction and repeated application to perform successfully. The end result is a list of years where the algorithm suggests that missing or double rings have occurred.