DYNAMIC-PROGRAMMING AS GRAPH SEARCHING - AN ALGEBRAIC APPROACH