Added the backward algorithm implementation