The k-NN algorithm works by finding the 'k' closest data points (neighbors) to a query point and classifying the query point based on the majority class among these neighbors. This method is particularly useful in histology where the classification of tissue samples based on morphological features is often required.