Daily Coding Quiz: Wednesday, 4 November 2026
All 10 coding questions with answers and explanations. 1 players took part.
Which traversal of a binary search tree visits the keys in sorted order?
DSA · easy · 100% of players got it right
- Preorder
- Postorder
- Inorder
- Level order
Answer: C. Inorder
Explanation: Inorder visits left subtree, node, right subtree. In a BST every left key is smaller and every right key larger, so the output is sorted.
What does feature scaling (e.g. standardisation) do?
Machine Learning · easy · 100% of players got it right
- Removes outliers
- Puts features on comparable scales, such as mean 0 and standard deviation 1
- Adds new features
- Balances the classes
Answer: B. Puts features on comparable scales, such as mean 0 and standard deviation 1
Explanation: Distance-based models (k-NN, SVM) and gradient descent behave badly when one feature ranges 0–1 and another 0–100,000. Tree models usually don’t need it.
Which algorithm is unsupervised?
Machine Learning · easy · 100% of players got it right
- Logistic regression
- K-means clustering
- Random forest classifier
- Linear regression
Answer: B. K-means clustering
Explanation: K-means groups unlabelled points by similarity. The others learn from labelled examples.
A Union-Find (disjoint set) structure is the standard helper in which algorithm?
DSA · medium · 100% of players got it right
- Dijkstra’s shortest path
- Kruskal’s minimum spanning tree
- Binary search
- KMP string matching
Answer: B. Kruskal’s minimum spanning tree
Explanation: Kruskal’s adds edges in order of weight and must check quickly whether an edge joins two different components. Union-Find answers that in near O(1).
How does a random forest reduce overfitting compared with a single decision tree?
Machine Learning · medium · 100% of players got it right
- It prunes one tree very deeply
- It averages many trees trained on bootstrap samples with random feature subsets
- It uses gradient descent
- It removes outliers automatically
Answer: B. It averages many trees trained on bootstrap samples with random feature subsets
Explanation: Bagging plus feature randomness makes the trees less correlated, so averaging them cuts variance a lot without raising bias much.
You scaled features using the mean and standard deviation of the whole dataset, then split it into train and test. What went wrong?
Machine Learning · medium · 100% of players got it right
- Nothing
- Data leakage: test-set statistics influenced training
- Underfitting
- The features are now categorical
Answer: B. Data leakage: test-set statistics influenced training
Explanation: Fit preprocessing on the training split only, then apply it to the test split (a scikit-learn Pipeline does this for you, including inside cross-validation).
On a dataset where 99% of transactions are not fraud, why is accuracy a poor metric?
Machine Learning · medium · 100% of players got it right
- Accuracy can’t be computed on imbalanced data
- A model that always predicts “not fraud” scores 99% while catching no fraud
- Accuracy is only for regression
- It overweights the minority class
Answer: B. A model that always predicts “not fraud” scores 99% while catching no fraud
Explanation: Use precision, recall, F1, PR-AUC or a cost-based metric that reflects missing the rare class.
What is the amortised time per append to a dynamic array that doubles its capacity when full?
DSA · hard · 100% of players got it right
- O(1)
- O(log n)
- O(n)
- O(√n)
Answer: A. O(1)
Explanation: Copying happens at sizes 1, 2, 4, …, n, totalling under 2n copies for n appends, so each append costs O(1) amortised, though a single append can be O(n).
What does the kernel trick in an SVM let you do?
Machine Learning · hard · 100% of players got it right
- Train without labels
- Fit a linear separator in a high-dimensional feature space using only dot products, without computing that space explicitly
- Avoid choosing a regularisation constant
- Turn an SVM into a decision tree
Answer: B. Fit a linear separator in a high-dimensional feature space using only dot products, without computing that space explicitly
Explanation: Replacing x·z with K(x, z), e.g. an RBF kernel, is equivalent to working in a much larger (even infinite) space. This gives non-linear boundaries at the cost of a kernel matrix.
PCA chooses its first principal component as the direction that:
Machine Learning · hard · 100% of players got it right
- Best separates the classes
- Has the maximum variance of the projected data (the top eigenvector of the covariance matrix)
- Has the minimum variance
- Is aligned with the first feature
Answer: B. Has the maximum variance of the projected data (the top eigenvector of the covariance matrix)
Explanation: PCA is unsupervised: it ignores labels. Separating classes is what LDA does.
Top 10
- Tushar: 227 points (10/10)