Your pseudocode should change this way:
kNN (dataset, sample){ 1. Go through each item in my dataset, and calculate the "distance" from that data item to my specific sample. 2. Classify the sample as the majority class between K samples in the dataset having minimum distance to the sample. }
This pseduocode has been illustrated int the following figure.
Suppose the data set consists of two classes A and B, shown as red and blue respectively, and we want to apply KNN with K=5 for to samples, shown with green and purple stars.
KNN computes the distance of each test sample to all the samples and finds five neighbors, having minimum distances to the test sample, and assign the majority class to the test sample.
Accuracy : 1 - (Number of misclassified test samples / Number of test samples)