K-nearest-neighbor algorithm for recognizing handwritten digits from the MNIST dataset