An Efficient Optimal Solution Algorithm for the Classification Problem