Algorithms for solving the inverse problem associated with KAK=As+1