Daily Coding Quiz: Saturday, 31 October 2026
All 10 coding questions with answers and explanations. 0 players took part.
Which data structure does breadth-first search (BFS) use to decide which node to visit next?
DSA · easy
- Stack
- Queue
- Priority queue
- Hash set
Answer: B. Queue
Explanation: BFS explores level by level: nodes are visited in the order they were discovered, which is exactly a FIFO queue. DFS uses a stack (or recursion).
Why is data augmentation (flips, crops, colour jitter) used when training vision models?
Computer Vision · easy
- To shrink the dataset
- To create realistic variations so the model generalises better
- To speed up inference
- To label images automatically
Answer: B. To create realistic variations so the model generalises better
Explanation: It teaches invariance (a cat flipped left-to-right is still a cat) and reduces overfitting. Choose augmentations that keep the label valid.
How many values describe one pixel of a standard RGB image?
Computer Vision · easy
- 1
- 3
- 4
- 8
Answer: B. 3
Explanation: Red, green and blue, usually each 0–255 (8 bits). RGBA adds a fourth alpha channel for transparency.
Kadane’s algorithm finds:
DSA · medium
- The longest increasing subsequence
- The maximum sum of a contiguous subarray
- The shortest path in a DAG
- The k-th smallest element
Answer: B. The maximum sum of a contiguous subarray
Explanation: Track the best sum ending at each index: max(x, best_ending_here + x). The best of those is the answer, in one O(n) pass.
Why does transfer learning from an ImageNet-pretrained CNN work well on a small custom dataset?
Computer Vision · medium
- ImageNet contains every class
- Early and middle layers learn general features (edges, textures, shapes) that carry over, so only the top layers need much new data
- It removes the need for labels
- It makes the model smaller
Answer: B. Early and middle layers learn general features (edges, textures, shapes) that carry over, so only the top layers need much new data
Explanation: Freeze or slowly fine-tune the backbone and train a new head. You need far fewer labelled images than training from scratch.
A 32 × 32 input passes through a 5 × 5 convolution with stride 1 and no padding. What is the output size?
Computer Vision · medium
- 32 × 32
- 28 × 28
- 27 × 27
- 30 × 30
Answer: B. 28 × 28
Explanation: Output = (N − K + 2P) / S + 1 = (32 − 5 + 0) / 1 + 1 = 28.
What is the difference between semantic and instance segmentation?
Computer Vision · medium
- There is none
- Semantic labels each pixel’s class; instance also separates individual objects of the same class
- Instance only works on video
- Semantic segmentation draws boxes
Answer: B. Semantic labels each pixel’s class; instance also separates individual objects of the same class
Explanation: Semantic: all people pixels are “person”. Instance (e.g. Mask R-CNN): person 1, person 2 and person 3 get separate masks.
What is the time complexity of Dijkstra’s algorithm with a binary heap on a graph with V vertices and E edges?
DSA · hard
- O(V²)
- O((V + E) log V)
- O(V + E)
- O(E · V)
Answer: B. O((V + E) log V)
Explanation: Each vertex is extracted once and each edge may push or decrease a key, each costing O(log V). With a Fibonacci heap it improves to O(E + V log V).
How does a Vision Transformer (ViT) feed an image to a Transformer?
Computer Vision · hard
- Pixel by pixel as tokens
- It splits the image into fixed-size patches (e.g. 16 × 16), linearly embeds each one and adds position embeddings
- It runs a CNN and discards the result
- It converts the image into a caption first
Answer: B. It splits the image into fixed-size patches (e.g. 16 × 16), linearly embeds each one and adds position embeddings
Explanation: A 224 × 224 image gives (224/16)² = 196 patch tokens plus a [CLS] token. Without convolution’s built-in locality, ViTs need lots of data or pretraining.
How does CLIP learn to connect images and text?
Computer Vision · hard
- By generating captions word by word
- With a contrastive objective: matching image–caption pairs get similar embeddings and mismatched pairs in the batch get dissimilar ones
- By training on ImageNet labels only
- With a diffusion loss
Answer: B. With a contrastive objective: matching image–caption pairs get similar embeddings and mismatched pairs in the batch get dissimilar ones
Explanation: Separate image and text encoders are trained on hundreds of millions of pairs. The shared embedding space enables zero-shot classification: compare an image with prompts like “a photo of a dog”.