Daily Coding Quiz: Sunday, 1 November 2026
All 10 coding questions with answers and explanations. 0 players took part.
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
DSA · easy
- Merge sort
- Quick sort
- Bubble sort
- Heap sort
Answer: C. Bubble sort
Explanation: Bubble sort compares neighbours and swaps them, so large values “bubble” to the end on each pass. It is O(n²).
Which of these is immutable?
Python · easy
- list
- dict
- set
- tuple
Answer: D. tuple
Explanation: A tuple cannot be changed after it is created, which is also why tuples (of hashable items) can be dictionary keys.
Which clause filters groups after GROUP BY?
SQL · easy
- WHERE
- HAVING
- ORDER BY
- LIMIT
Answer: B. HAVING
Explanation: WHERE filters rows before grouping; HAVING filters the groups, so it can use aggregates like COUNT(*) > 5.
What is the space complexity of a recursive DFS on a tree of height h (ignoring the output)?
DSA · medium
- O(1)
- O(h)
- O(n log n)
- O(2^h)
Answer: B. O(h)
Explanation: The call stack holds one frame per level on the current root-to-node path, so at most h + 1 frames.
Which statements about gradient boosting (e.g. XGBoost, LightGBM) are true? (Select all that apply)
Machine Learning · medium
- Trees are built one after another, each correcting the previous errors
- Trees are built independently in parallel like a random forest
- A learning rate shrinks each tree’s contribution
- It can overfit if you add too many trees
Answer: A. Trees are built one after another, each correcting the previous errors; C. A learning rate shrinks each tree’s contribution; D. It can overfit if you add too many trees
Explanation: Boosting is sequential: each tree fits the residual errors (gradients) of the current ensemble. Shrinkage and early stopping keep it from overfitting.
In a Transformer, why is positional information added to the token embeddings?
AI & GenAI · medium
- To save memory
- Self-attention by itself ignores order, so position must be encoded explicitly
- To normalise the inputs
- To make tokens unique
Answer: B. Self-attention by itself ignores order, so position must be encoded explicitly
Explanation: Attention treats its input as a set. Sinusoidal, learned or rotary (RoPE) position encodings tell the model where each token is.
Predicted box A and ground-truth box B each have area 100 and overlap by 50. What is their IoU?
Computer Vision · medium
- 0.25
- 0.33
- 0.5
- 0.67
Answer: B. 0.33
Explanation: IoU = intersection / union = 50 / (100 + 100 − 50) = 50 / 150 ≈ 0.33.
What is the minimum number of comparisons any comparison-based sort needs in the worst case?
DSA · hard
- Θ(n)
- Θ(n log n)
- Θ(n²)
- Θ(log n)
Answer: B. Θ(n log n)
Explanation: There are n! possible orders, and a decision tree with n! leaves has height ≥ log₂(n!) = Θ(n log n). Counting sort beats this only by not comparing.
What is printed?
Python · hard
print(all([]), any([]), bool([[]]))- True False True
- False False False
- True True True
- False False True
Answer: A. True False True
Explanation: all() of nothing is True (no element is false), any() of nothing is False. [[]] is a non-empty list, so it is truthy even though its item is empty.
What does the running total return for the third row?
SQL · hard
SELECT d, amt, SUM(amt) OVER (ORDER BY d) AS running FROM sales; -- rows (d, amt): ('2026-01-01', 10), ('2026-01-02', 20), ('2026-01-02', 5), ('2026-01-03', 7)- 30
- 35
- 5
- 42
Answer: B. 35
Explanation: With ORDER BY and no frame clause the default frame is RANGE … CURRENT ROW, which includes all peers with the same d. Both 2026-01-02 rows show 10 + 20 + 5 = 35. Use ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW for a strict row-by-row total.