Hack4Hack

Daily Coding Quiz: Wednesday, 11 November 2026

All 10 coding questions with answers and explanations. 0 players took part.

  1. What is the time complexity of binary search on a sorted array of n elements?

    DSA · easy

    1. O(n)
    2. O(log n)
    3. O(n log n)
    4. O(1)

    Answer: B. O(log n)

    Explanation: Each comparison halves the remaining range, so at most about log₂ n steps are needed.

  2. A model scores 99% on training data and 62% on test data. This is most likely:

    Machine Learning · easy

    1. Underfitting
    2. Overfitting
    3. Data leakage
    4. A perfect model

    Answer: B. Overfitting

    Explanation: A big gap between training and test performance means the model memorised the training set instead of learning patterns that generalise.

  3. Predicting house prices from size and location is which kind of problem?

    Machine Learning · easy

    1. Classification
    2. Regression
    3. Clustering
    4. Dimensionality reduction

    Answer: B. Regression

    Explanation: The target is a continuous number, so it is regression. Predicting a category (spam / not spam) would be classification.

  4. How many distinct ways are there to climb 5 stairs taking 1 or 2 steps at a time?

    DSA · medium

    1. 5
    2. 8
    3. 10
    4. 13

    Answer: B. 8

    Explanation: ways(n) = ways(n−1) + ways(n−2) with ways(1)=1, ways(2)=2: 1, 2, 3, 5, 8. It is the Fibonacci sequence.

  5. Increasing k in k-NN generally:

    Machine Learning · medium

    1. Increases variance, decreases bias
    2. Decreases variance, increases bias (smoother boundary)
    3. Has no effect
    4. Always improves accuracy

    Answer: B. Decreases variance, increases bias (smoother boundary)

    Explanation: k = 1 follows every noisy point (high variance). Larger k averages over more neighbours, smoothing the boundary but possibly missing real detail.

  6. What does an ROC-AUC of 0.5 mean?

    Machine Learning · medium

    1. Perfect classifier
    2. No better than random ranking
    3. 50% accuracy exactly
    4. The model is always wrong

    Answer: B. No better than random ranking

    Explanation: AUC is the chance a random positive is scored above a random negative. 0.5 is coin-flip ranking; 1.0 is perfect.

  7. A cancer test flags 100 people; 80 really have cancer. Out of 120 people who have cancer, 80 were flagged. What are precision and recall?

    Machine Learning · medium

    1. Precision 80%, recall 66.7%
    2. Precision 66.7%, recall 80%
    3. Both 80%
    4. Precision 40%, recall 80%

    Answer: A. Precision 80%, recall 66.7%

    Explanation: Precision = TP / flagged = 80/100 = 80%. Recall = TP / actual positives = 80/120 ≈ 66.7%.

  8. Which statement about strongly connected components (SCCs) is true?

    DSA · hard

    1. They only exist in undirected graphs
    2. Tarjan’s and Kosaraju’s algorithms find all SCCs in O(V + E)
    3. Finding SCCs needs O(V³) Floyd–Warshall
    4. Every DAG has exactly one SCC

    Answer: B. Tarjan’s and Kosaraju’s algorithms find all SCCs in O(V + E)

    Explanation: Both run DFS-based passes in linear time. In a DAG every vertex is its own SCC, so a DAG with V vertices has V SCCs.

  9. The bias–variance decomposition of expected squared error is:

    Machine Learning · hard

    1. Bias + Variance
    2. Bias² + Variance + irreducible noise
    3. Bias × Variance
    4. Variance − Bias²

    Answer: B. Bias² + Variance + irreducible noise

    Explanation: E[(y − ŷ)²] = Bias[ŷ]² + Var[ŷ] + σ². The noise term σ² is a floor no model can beat.

  10. Why does logistic regression use log-loss (cross-entropy) instead of mean squared error?

    Machine Learning · hard

    1. MSE cannot be computed for probabilities
    2. With a sigmoid, MSE gives a non-convex loss with weak gradients, while log-loss is convex and matches maximum likelihood
    3. Log-loss is faster to compute
    4. MSE always overfits

    Answer: B. With a sigmoid, MSE gives a non-convex loss with weak gradients, while log-loss is convex and matches maximum likelihood

    Explanation: Cross-entropy is the negative log-likelihood of a Bernoulli model. Combined with a sigmoid it is convex in the weights, so gradient descent finds the global optimum.

Play the next Daily Quiz at 4 PM IST