Daily Coding Quiz: Wednesday, 18 November 2026
All 10 coding questions with answers and explanations. 0 players took part.
Which of these is a stable sorting algorithm by default?
DSA · easy
- Quick sort
- Heap sort
- Merge sort
- Selection sort
Answer: C. Merge sort
Explanation: Merge sort keeps equal elements in their original order (take from the left half on ties). Standard quick, heap and selection sort do not.
What does feature scaling (e.g. standardisation) do?
Machine Learning · easy
- 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
- 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.
Floyd’s “tortoise and hare” algorithm is mainly used to:
DSA · medium
- Sort a linked list
- Detect a cycle in a linked list
- Reverse a linked list
- Merge two sorted lists
Answer: B. Detect a cycle in a linked list
Explanation: One pointer moves 1 step, the other 2. If there is a cycle the fast pointer eventually meets the slow one; if not, it reaches the end.
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
- 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).
How does a random forest reduce overfitting compared with a single decision tree?
Machine Learning · medium
- 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.
On a dataset where 99% of transactions are not fraud, why is accuracy a poor metric?
Machine Learning · medium
- 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 time complexity of the classic dynamic-programming solution to the Longest Common Subsequence of strings of length m and n?
DSA · hard
- O(m + n)
- O(m · n)
- O(2^(m+n))
- O((m + n) log(m + n))
Answer: B. O(m · n)
Explanation: The DP table has (m+1)(n+1) cells and each is filled in O(1) from its neighbours.
What does the kernel trick in an SVM let you do?
Machine Learning · hard
- 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.
You tune hyperparameters with cross-validation on the full dataset and report the best CV score as your final result. What is the problem?
Machine Learning · hard
- None
- The score is optimistically biased: you selected the best of many tries on the same folds. Use nested CV or a held-out test set
- Cross-validation can’t tune hyperparameters
- The model will underfit
Answer: B. The score is optimistically biased: you selected the best of many tries on the same folds. Use nested CV or a held-out test set
Explanation: Picking the maximum over many configurations overfits to the validation folds. Nested cross-validation, or a final test set untouched during tuning, gives an honest estimate.