Daily Coding Quiz: Wednesday, 28 October 2026
All 10 coding questions with answers and explanations. 1 players took part.
Accessing the element at index i of an array takes:
DSA · easy · 0% of players got it right
- O(1)
- O(log n)
- O(i)
- O(n)
Answer: A. O(1)
Explanation: Array elements sit in contiguous memory, so the address is base + i × size: one calculation, no matter how large the array.
Predicting house prices from size and location is which kind of problem?
Machine Learning · easy · 100% of players got it right
- Classification
- Regression
- Clustering
- 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.
A model scores 99% on training data and 62% on test data. This is most likely:
Machine Learning · easy · 100% of players got it right
- Underfitting
- Overfitting
- Data leakage
- 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.
What is the worst-case time complexity of quick sort?
DSA · medium · 0% of players got it right
- O(n)
- O(n log n)
- O(n²)
- O(log n)
Answer: C. O(n²)
Explanation: If the pivot is always the smallest or largest element (e.g. first element on sorted input), partitions are n−1 and 0, giving n + (n−1) + … = O(n²).
Increasing k in k-NN generally:
Machine Learning · medium · 0% of players got it right
- Increases variance, decreases bias
- Decreases variance, increases bias (smoother boundary)
- Has no effect
- 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.
What does an ROC-AUC of 0.5 mean?
Machine Learning · medium · 0% of players got it right
- Perfect classifier
- No better than random ranking
- 50% accuracy exactly
- 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.
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 · 0% of players got it right
- Precision 80%, recall 66.7%
- Precision 66.7%, recall 80%
- Both 80%
- 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%.
What does this print?
DSA · hard · 0% of players got it right
from functools import lru_cache @lru_cache(None) def ways(n, k): # ways to write n as an ordered sum of parts each <= k if n == 0: return 1 return sum(ways(n - p, k) for p in range(1, min(n, k) + 1)) print(ways(4, 2))- 3
- 4
- 5
- 8
Answer: C. 5
Explanation: Ordered sums of 4 using 1s and 2s: 1111, 112, 121, 211, 22 → 5. With k=2 it is the stair-climbing Fibonacci again: ways(4) = 5.
The bias–variance decomposition of expected squared error is:
Machine Learning · hard · 0% of players got it right
- Bias + Variance
- Bias² + Variance + irreducible noise
- Bias × Variance
- Variance − Bias²
Answer: B. Bias² + Variance + irreducible noise
Explanation: E[(y − ŷ)²] = Bias[ŷ]² + Var[ŷ] + σ². The noise term σ² is a floor no model can beat.
Why does logistic regression use log-loss (cross-entropy) instead of mean squared error?
Machine Learning · hard · 0% of players got it right
- MSE cannot be computed for probabilities
- With a sigmoid, MSE gives a non-convex loss with weak gradients, while log-loss is convex and matches maximum likelihood
- Log-loss is faster to compute
- 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.
Top 10
- Vaishanavi Patil: 28 points (2/10)