Hack4Hack

Daily Coding Quiz: Saturday, 31 October 2026

All 10 coding questions with answers and explanations. 0 players took part.

  1. Which data structure does breadth-first search (BFS) use to decide which node to visit next?

    DSA · easy

    1. Stack
    2. Queue
    3. Priority queue
    4. 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).

  2. Why is data augmentation (flips, crops, colour jitter) used when training vision models?

    Computer Vision · easy

    1. To shrink the dataset
    2. To create realistic variations so the model generalises better
    3. To speed up inference
    4. 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.

  3. How many values describe one pixel of a standard RGB image?

    Computer Vision · easy

    1. 1
    2. 3
    3. 4
    4. 8

    Answer: B. 3

    Explanation: Red, green and blue, usually each 0–255 (8 bits). RGBA adds a fourth alpha channel for transparency.

  4. Kadane’s algorithm finds:

    DSA · medium

    1. The longest increasing subsequence
    2. The maximum sum of a contiguous subarray
    3. The shortest path in a DAG
    4. 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.

  5. Why does transfer learning from an ImageNet-pretrained CNN work well on a small custom dataset?

    Computer Vision · medium

    1. ImageNet contains every class
    2. Early and middle layers learn general features (edges, textures, shapes) that carry over, so only the top layers need much new data
    3. It removes the need for labels
    4. 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.

  6. A 32 × 32 input passes through a 5 × 5 convolution with stride 1 and no padding. What is the output size?

    Computer Vision · medium

    1. 32 × 32
    2. 28 × 28
    3. 27 × 27
    4. 30 × 30

    Answer: B. 28 × 28

    Explanation: Output = (N − K + 2P) / S + 1 = (32 − 5 + 0) / 1 + 1 = 28.

  7. What is the difference between semantic and instance segmentation?

    Computer Vision · medium

    1. There is none
    2. Semantic labels each pixel’s class; instance also separates individual objects of the same class
    3. Instance only works on video
    4. 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.

  8. What is the time complexity of Dijkstra’s algorithm with a binary heap on a graph with V vertices and E edges?

    DSA · hard

    1. O(V²)
    2. O((V + E) log V)
    3. O(V + E)
    4. 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).

  9. How does a Vision Transformer (ViT) feed an image to a Transformer?

    Computer Vision · hard

    1. Pixel by pixel as tokens
    2. It splits the image into fixed-size patches (e.g. 16 × 16), linearly embeds each one and adds position embeddings
    3. It runs a CNN and discards the result
    4. 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.

  10. How does CLIP learn to connect images and text?

    Computer Vision · hard

    1. By generating captions word by word
    2. With a contrastive objective: matching image–caption pairs get similar embeddings and mismatched pairs in the batch get dissimilar ones
    3. By training on ImageNet labels only
    4. 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”.

Play the next Daily Quiz at 4 PM IST