Implemented recursive backtracker algorithm.