chapter

    Decision Trees, Naive Bayes and K-nearest Neighbors Practice Questions for Gate Da

    Solve 343+ Decision Trees, Naive Bayes and K-nearest Neighbors practice questions for GATE DA with answers and detailed solutions. Free sample questions below

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    Level 1: Warm-up

    When finding the nearest neighbors using Euclidean distance, which of the following statements about using squared Euclidean distance is ALWAYS true?

    Question 2
    Level 1: Warm-up

    Which of the following scenarios is IMPOSSIBLE in a standard -nearest neighbors classification setup?

    Question 3
    Level 1: Warm-up

    A one-dimensional dataset contains two points: at (Class A) and at (Class B). A query point lies on the same axis at position . For to be strictly classified as Class A using the $1$-nearest neighbor algorithm and Euclidean distance, which of the following statements about must be true?

    Question 4
    Level 1: Warm-up

    Which of the following scenarios is IMPOSSIBLE for a standard -nearest neighbors classifier?

    Question 5
    Level 1: Warm-up
    Match the following Naive Bayes scenarios with the total number of independent parameters to estimate: List I (Scenario) P) 2 classes, 2 binary features Q) 3 classes, 2 binary features R) 2 classes, 4 binary features List II (Parameters) 1) 5 2) 8 3) 9
    Question 6
    Level 1: Warm-up

    In a Naive Bayes classifier with 2 classes and binary attributes, how many independent parameters need to be estimated in total? (Hint: Remember that probabilities for each variable must sum to 1.)

    Question 7
    Level 1: Warm-up

    A Naive Bayes classifier has 3 classes and 2 discrete features. Feature 1 has 3 possible values, and Feature 2 also has 3 possible values. What is the minimum number of independent parameters that must be estimated for this classifier?

    Question 8
    Level 1: Warm-up
    Consider the following statements about a Naive Bayes classifier with 2 classes and binary attributes: S1: The number of independent prior parameters is 1. S2: The number of independent conditional parameters per attribute is 2. S3: The total number of independent parameters to estimate is . Which of the above statements are CORRECT?
    Question 9
    Level 1: Warm-up

    A dataset contains 10 examples with two classes: 5 positive and 5 negative. What is the maximum possible entropy of this dataset?

    Question 10
    Level 1: Warm-up

    A dataset has 4 examples: 2 positive and 2 negative. Attribute splits the data into two subsets: contains {1 positive, 1 negative} and contains {1 positive, 1 negative}. What is the Information Gain of attribute ?

    Free preview ends here

    Login to view the complete practice questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Decision Trees, Naive Bayes and K-nearest Neighbors Practice Questions for GATE DA

    Solve 343+ Decision Trees, Naive Bayes and K-nearest Neighbors practice questions for GATE DA with answers and detailed solutions. Free sample questions below.

    Chapter Roadmap: Decision Trees, Naive Bayes and k-NN

    Chapter Roadmap

    Decision Trees, Naive Bayes & k-NN

    01 | k-Nearest Neighbors
    Instance-based, lazy learning. Distance metrics, choosing k, decision boundaries.
    02 | Naive Bayes
    Generative, probability-based. Conditional independence, priors, likelihoods.
    03 | Decision Trees
    Eager, rule-based. Attribute splits, impurity measures, pruning.
    What you will master: How each classifier predicts, solving numerical problems step-by-step, and comparing methods by cost and assumptions.

    k-Nearest Neighbors Classification

    k-Nearest Neighbors

    "A point is classified by the company it keeps."

    What you will learn
    • Why k-NN is an instance-based and lazy learner.
    • How to use distance metrics to find nearest points.
    • How the choice of k changes the decision boundary.
    • How to solve small numerical prediction problems safely.
    • Common traps: ties, even k, and high-dimensional data.
    Context: The simplest non-parametric classifier in this chapter, showing a purely distance-driven way of thinking.

    Decision Trees, Naive Bayes and K-nearest Neighbors: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Machine Learning MCQ

    When finding the nearest neighbors using Euclidean distance, which of the following statements about using squared Euclidean distance is ALWAYS true?

    1. A.

      It changes the relative order of distances between the query point and the training points.

    2. B.

      It provides a strict upper bound on the actual Euclidean distances.

    3. C.

      It preserves the relative ordering of distances, allowing correct identification of the nearest neighbors.

    4. D.

      It is only valid when the features are standardized to zero mean and unit variance.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: Squaring is a monotonic transformation for non-negative values, which preserves the relative order.

    Step 1: Euclidean distance is always non-negative. The squared Euclidean distance is .

    Step 2: For any two non-negative numbers and , if , then . This means the relative ordering of distances is perfectly preserved.

    Step 3: Since k-NN only relies on the <b>relative order</b> of distances to find the nearest neighbors (not the actual distance values), using squared distances yields the exact same neighbors.

    Step 4: This is a standard exam optimization to avoid computing square roots.

    Answer: It preserves the relative ordering of distances, allowing correct identification of the nearest neighbors.

    Question 2 · Machine Learning MCQ

    Which of the following scenarios is IMPOSSIBLE in a standard -nearest neighbors classification setup?

    1. A.

      The training phase requires estimating a fixed set of model parameters from the data.

    2. B.

      The prediction time complexity is , where is the number of training points and is the number of features.

    3. C.

      The decision boundary separating the classes is highly non-linear.

    4. D.

      The algorithm is applied to a dataset with more than two classes.

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Identify the core defining property of k-NN that makes certain scenarios impossible.

    Step 1: Evaluate Option A. k-NN is a lazy, non-parametric learner. Its training phase simply stores the data; it does <b>not</b> estimate any model parameters. Therefore, this scenario is <b>Impossible</b>.

    Step 2: Evaluate Option B. k-NN prediction requires computing distances to all points in dimensions, so is the correct complexity. This is <b>Possible</b>.

    Step 3: Evaluate Option C. k-NN can produce highly non-linear decision boundaries because it relies on local neighborhood voting. This is <b>Possible</b>.

    Step 4: Evaluate Option D. k-NN naturally extends to multi-class classification by taking a majority vote among more than two classes. This is <b>Possible</b>.

    Answer: The training phase requires estimating a fixed set of model parameters from the data.

    Question 3 · Machine Learning MCQ

    A one-dimensional dataset contains two points: at (Class A) and at (Class B). A query point lies on the same axis at position . For to be strictly classified as Class A using the $1$-nearest neighbor algorithm and Euclidean distance, which of the following statements about must be true?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: 1-NN assigns the class of the single closest point. Strict classification requires a unique closest point.

    Step 1: The distance from to is .

    Step 2: The distance from to is .

    Step 3: For to be strictly classified as Class A, it must be strictly closer to than to . Thus, .

    Step 4: Solving this inequality: .

    Step 5: If , the distances are equal (a tie), so it is not strictly classified as A. Therefore, must be strictly less than 3.

    Answer:

    Question 4 · Machine Learning MCQ

    Which of the following scenarios is IMPOSSIBLE for a standard -nearest neighbors classifier?

    1. A.

      It achieves zero training error when .

    2. B.

      It uses a gradient descent algorithm to update internal feature weights during the training phase.

    3. C.

      It produces a highly non-linear decision boundary that adapts to local data structures.

    4. D.

      Its classification performance degrades significantly if features are not scaled and have vastly different ranges.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: Identify the core mechanism of k-NN and what it fundamentally lacks.

    Step 1: Evaluate Option A. When , k-NN memorizes the training data. Every training point is its own nearest neighbor, so the training error is exactly zero. This is <b>Possible</b>.

    Step 2: Evaluate Option B. k-NN is a non-parametric, instance-based learner. It does not have internal feature weights, nor does it use a loss function or gradient descent to optimize anything during training. It simply stores the data. This is <b>Impossible</b>.

    Step 3: Evaluate Option C. k-NN decision boundaries are inherently non-linear and adapt to the local neighborhood of the data. This is <b>Possible</b>.

    Step 4: Evaluate Option D. k-NN uses distance metrics, which are scale-dependent. Without scaling, larger ranges dominate, degrading performance. This is <b>Possible</b>.

    Answer: It uses a gradient descent algorithm to update internal feature weights during the training phase.

    Question 5 · Machine Learning MCQ
    Match the following Naive Bayes scenarios with the total number of independent parameters to estimate: List I (Scenario) P) 2 classes, 2 binary features Q) 3 classes, 2 binary features R) 2 classes, 4 binary features List II (Parameters) 1) 5 2) 8 3) 9
    1. A.

      P-1, Q-2, R-3

    2. B.

      P-2, Q-3, R-1

    3. C.

      P-1, Q-3, R-2

    4. D.

      P-3, Q-2, R-1

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a parameter counting question with multiple scenarios — apply the formula to each case.

    Formula: Total parameters =

    Step 1: Calculate for P) , , :

    Prior:

    Conditional:

    Total: → matches 1)

    Step 2: Calculate for Q) , , :

    Prior:

    Conditional:

    Total: → matches 2)

    Step 3: Calculate for R) , , :

    Prior:

    Conditional:

    Total: → matches 3)

    Answer: P-1, Q-2, R-3 (Option A)

    Common trap: Overcounting by forgetting to subtract 1 for the probability sum constraint.

    Question 6 · Machine Learning NAT

    In a Naive Bayes classifier with 2 classes and binary attributes, how many independent parameters need to be estimated in total? (Hint: Remember that probabilities for each variable must sum to 1.)

    Correct Answer:

    11.00

    Step-by-Step Solution

    Key idea: This is a direct application of the parameter counting formula for binary attributes.

    Step 1: Recall the formula for total independent parameters:

    Step 2: For binary attributes, for all , so:

    Step 3: Substitute , :

    Answer: 11.00

    Common trap: Forgetting to subtract 1 for the prior constraint (would get ).

    Question 7 · Machine Learning MCQ

    A Naive Bayes classifier has 3 classes and 2 discrete features. Feature 1 has 3 possible values, and Feature 2 also has 3 possible values. What is the minimum number of independent parameters that must be estimated for this classifier?

    1. A.

      21

    2. B.

      14

    3. C.

      15

    4. D.

      20

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a parameter counting question — use the formula for independent parameters, remembering that probabilities must sum to 1.

    Step 1: Recall the formula for total independent parameters:

    Step 2: Identify the given values:

    • (number of classes)
    • (number of features)
    • (values for Feature 1)
    • (values for Feature 2)

    Step 3: Calculate prior parameters:

    Step 4: Calculate conditional parameters for each feature:

    • Feature 1:
    • Feature 2:

    Step 5: Sum all parameters:

    Answer: 14 (Option B)

    Common trap: Overcounting by forgetting to subtract 1 for the probability sum constraint, which yields .

    Question 8 · Machine Learning MCQ
    Consider the following statements about a Naive Bayes classifier with 2 classes and binary attributes: S1: The number of independent prior parameters is 1. S2: The number of independent conditional parameters per attribute is 2. S3: The total number of independent parameters to estimate is . Which of the above statements are CORRECT?
    1. A.

      S1 and S2 only

    2. B.

      S2 and S3 only

    3. C.

      S1 and S3 only

    4. D.

      S1, S2, and S3

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a statement truth question — evaluate each statement using the parameter counting formulas for binary attributes.

    Step 1: Evaluate S1 — prior parameters.

    For classes, prior parameters = .

    S1 is CORRECT. ✓

    Step 2: Evaluate S2 — conditional parameters per attribute.

    For binary attributes () and classes:

    Conditional parameters per attribute = .

    S2 is CORRECT. ✓

    Step 3: Evaluate S3 — total parameters.

    Total = Prior + (K × Conditional per attribute)

    Total = .

    S3 claims the total is , which is INCORRECT. ✗

    Answer: S1 and S2 only (Option A)

    Common trap: Ignoring the constraint that probabilities sum to 1, leading to S3 being considered correct (would give instead of ).

    Question 9 · Machine Learning NAT

    A dataset contains 10 examples with two classes: 5 positive and 5 negative. What is the maximum possible entropy of this dataset?

    Correct Answer:

    1.00

    Step-by-Step Solution

    Key idea: This is an observation question — recognize that entropy is maximized when classes are perfectly balanced.

    Step 1: Recall the entropy formula for binary classification:

    Step 2: The dataset has 5 positive and 5 negative examples out of 10 total.

    Step 3: Calculate the entropy:

    Answer: 1.00

    Key insight: For binary classification, entropy is maximized at 1.0 when the dataset is perfectly balanced (50-50 split). This is the maximum possible entropy for any binary dataset.

    Common trap: Thinking that maximum entropy occurs when all examples belong to one class (which gives entropy = 0, the minimum).

    Question 10 · Machine Learning NAT

    A dataset has 4 examples: 2 positive and 2 negative. Attribute splits the data into two subsets: contains {1 positive, 1 negative} and contains {1 positive, 1 negative}. What is the Information Gain of attribute ?

    Correct Answer:

    0.00

    Step-by-Step Solution

    Key idea: This is a contradiction question — the attribute provides no useful information because it doesn't reduce impurity at all.

    Step 1: Calculate the parent entropy .

    Parent has 2 positive, 2 negative out of 4 total.

    ,

    Step 2: Calculate the entropy of each child subset.

    • : 1 positive, 1 negative → , →
    • : 1 positive, 1 negative → , →

    Step 3: Calculate the weighted average of child entropies.

    Weights: ,

    Weighted average =

    Step 4: Calculate Information Gain.

    Answer: 0.00

    Key insight: When an attribute splits the data into subsets with the same impurity as the parent, the Information Gain is zero. This attribute provides no useful information for classification.

    Common trap: Overcounting by thinking any split must provide some information gain, or making calculation errors in the entropy formula.

    More practice questions in this unit