k-NN: past questions

14 questions · 38 marks · 8 papers. Try each one before checking.

Solve them and check answers →Read the notes first

Aug 2025 (03 Aug)

Question Q10 SA · 3 marks

Perform a 3-NN regressor for the following dataset: $(x_1,x_2,y)$: $(1,2,3.5)$, $(2,1,2.8)$, $(3,3,5.1)$, $(4,2,4.7)$, $(5,3,6.2)$, $(6,1,5.9)$, where $x=[x_1\ x_2]^T$ is a feature vector and $y$ is the label. What will be the predicted value for the test data point $[3\ 2]^T$? Enter the answer correct to one decimal place.

Type your answer on the interactive page.

Apr 2026 (06 Apr)

Question Q5 MCQ · 3 marks

Figure (described in words): a test point at $(0,0)$; dashed circles of radius $1,2,3,4$ around it. Training points: one green square ($+1$) at distance $1$ (first quadrant); one red circle ($-1$) at distance $2$ (second quadrant); one red circle ($-1$) at distance $3$ (fourth quadrant); one red circle ($-1$) at distance $4$ (third quadrant).
Consider a training dataset for a classification problem with four data-points. Red circles represent data-points with label $-1$ and green squares represent data-points with label $+1$. A test-point is located at $(0,0)$. Dotted circles centered at $(0,0)$ with radii $1,2,3$ and $4$ are drawn for your convenience. KNN with Euclidean distance and $k=3$ is the classifier. Now, a new training data-point with label $+1$ is added somewhere inside the outermost circle of radius $4$ such that it leaves the predicted label of the test data-point unchanged. Let $S$ be the set of all points that could be the potential location of this new training data-point. Find the area of the region corresponding to $S$. Note: We use KNN with $k=3$ for both datasets.
  1. $7\pi$
  2. $5\pi$
  3. $16\pi$
  4. $9\pi$

Question Q17 SA · 3 marks

Perform a 3-NN regressor for the following dataset: $(x_1,x_2,y)$: $(2,3,4.1)$, $(1,4,3.2)$, $(4,2,5.5)$, $(3,5,6.8)$, $(5,2,7.1)$, $(2,1,3.9)$. What will be the predicted value for the test data point $x_{test}=[2\ 2]^T$? Enter the answer correct to one decimal place.

Type your answer on the interactive page.

Aug 2026 (14 Aug)

Question Q10 MSQ · 4 marks

Which of the following statements about the K-Nearest Neighbours (KNN) algorithm are correct?
  1. The choice of distance metric can affect the predicted class.
  2. Once trained, KNN makes predictions without referring to the training data.
  3. Every prediction does not require computing distances from the test point to all training data.
  4. The computational cost of prediction generally increases with the size of the training dataset.

Dec 2024 (01 Dec)

Question Q14 MCQ · 2 marks

A binary classification problem has a training dataset of $100$ points, evenly distributed between two classes ($50$ in each class). You train a $k$-NN algorithm with $k=3$. Each point is considered its own neighbor during classification.
Assuming there are outliers, the decision boundary becomes smoother with decreasing value of $k$ in a $k$-NN algorithm.
  1. TRUE
  2. FALSE

Question Q13 SA · 3 marks

A binary classification problem has a training dataset of $100$ points, evenly distributed between two classes ($50$ in each class). You train a $k$-NN algorithm with $k=3$. Each point is considered its own neighbor during classification.
What is the minimum number of misclassifications that can occur in the training dataset when using this $k$-NN algorithm?

Type your answer on the interactive page.

Question Q9 SA · 4 marks

Consider the following feature vectors in $\mathbb R^3$: $x_1=[1,2,3]^T$, $x_2=[-1,-2,0]^T$, $x_3=[3,0,1]^T$, $x_4=[0,1,4]^T$, $x_5=[2,-1,-3]^T$. The labels of these points are: $y_1=0$, $y_2=1$, $y_3=1$, $y_4=0$, $y_5=1$. If we use a $k$-NN algorithm with $k=3$ what would be the predicted label for the following test point: $x_{test}=[1,1,2]^T$

Type your answer on the interactive page.

Mar 2024 (24 Mar)

Question Q3 SA · 3 marks

A binary classification problem has a training dataset of $80$ points, evenly distributed between two classes ($40$ in each class). You train a $k$-NN algorithm with $k=3$. Each point is considered its own neighbor during classification.
What is the minimum number of misclassifications that can occur in the training dataset when using this $k$-NN algorithm?

Type your answer on the interactive page.

Question Q4 SA · 2 marks

A binary classification problem has a training dataset of $80$ points, evenly distributed between two classes ($40$ in each class). You train a $k$-NN algorithm with $k=3$. Each point is considered its own neighbor during classification.
Assuming there are outliers, the decision boundary becomes smoother with increasing value of $k$ in a $k$-NN algorithm (Fill in $1$ for yes and $0$ for no).

Type your answer on the interactive page.

Dec 2023 (day not given)

Question Q13 SA · 2 marks

Given a training dataset with $100$ data points, how many distances would we have to compute in the process of predicting the label of test-point in the $k$-NN algorithm with $k=5$

Type your answer on the interactive page.

Mar 2025 (16 Mar)

Question Q15 SA · 2 marks

Consider the 2D data points with labels: $[1\ 1]^T\to1$, $[1\ -1]^T\to1$, $[2\ 1]^T\to1$, $[2\ 2]^T\to1$, $[2\ -2]^T\to0$, $[3\ -3]^T\to0$, $[4\ -1]^T\to1$.
If we use a $k$-NN algorithm with $k=3$, what would be the predicted label for $x_{test}=[4\ 0]^T$?

Type your answer on the interactive page.

Question Q16 SA · 3 marks

Same seven points: $[1\ 1]\to1$, $[1\ -1]\to1$, $[2\ 1]\to1$, $[2\ 2]\to1$, $[2\ -2]\to0$, $[3\ -3]\to0$, $[4\ -1]\to1$.
Compute the Leave-one-out cross validation (LOOCV) error for the 3-nearest neighbour (3-NN) algorithm on this dataset. Enter the answer correct to two decimal places.

Type your answer on the interactive page.

Question Q17 MCQ · 2 marks

Same seven points and labels as the previous question.
Is it possible to reduce the cross-validation error obtained in the previous question by changing the label of certain points?
  1. Yes
  2. No
  3. Cannot conclude from the given information.

Jul 2022 (day not given)

Question Q11 SA · 2 marks

You are given a training dataset of $100$ data-points for a regression task. You wish to use a $k$-NN regressor, with $k=10$. $d(x_i,x_j)$ is a function that returns the distance between two points $x_i$ and $x_j$. Calling $d$ on a pair of points corresponds to a single distance computation. If you want to predict the label of a new test point, how many distances would you have to compute?

Type your answer on the interactive page.

Check your answers →

Weeks covering this topic

Other MLT topics