Effective Algorithms for a Class of Discrete Valued Optimal Control Problems