What is the function of k in KNN




While learning about KNN I came across:

My confusion arises from the part in the red rectangle.In the case of k = 1 we are comparing the distances from all the other data points and selecting the minimum one.
In case of k = 3 we calculate distances from data points,select the 3 points which have minimum distance and then among those 3 the point whose distance is minimum,it’s class is assigned to the data point.
Since ultimately we are selecting only one class label for the data point via using the minimum distance method,what essential difference does the value of k bring out??
Can someone please help me understand this??



A case is classified by a majority vote of its neighbors, with the case being assigned to the class most common amongst its K(number of nearest neighbors to take of the data point to be classified) nearest neighbors by a distance.

If K=1, then the case is simply assigned to the class of its nearest neighbor.

Hope this helps!