Hack4Hack

Daily Coding Quiz: Friday, 6 November 2026

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

  1. What is the maximum number of nodes in a binary tree of height 3 (a single root has height 0)?

    DSA · easy

    1. 7
    2. 8
    3. 15
    4. 16

    Answer: C. 15

    Explanation: Levels 0 to 3 hold 1 + 2 + 4 + 8 = 15 nodes, i.e. 2^(h+1) − 1.

  2. What is the average time complexity of looking up a key in a hash table?

    DSA · easy

    1. O(1)
    2. O(log n)
    3. O(n)
    4. O(n²)

    Answer: A. O(1)

    Explanation: With a good hash function and load factor, a lookup touches a constant number of buckets on average. The worst case (everything colliding) is O(n).

  3. Which activation function outputs max(0, x)?

    AI & GenAI · easy

    1. Sigmoid
    2. Tanh
    3. ReLU
    4. Softmax

    Answer: C. ReLU

    Explanation: ReLU passes positive values unchanged and zeroes negatives. It is cheap and avoids the vanishing gradients of sigmoid and tanh for positive inputs.

  4. In an LLM, what is a “token”?

    AI & GenAI · easy

    1. Always one whole word
    2. A chunk of text (a word, part of a word or punctuation) the model reads and writes
    3. An API key
    4. One sentence

    Answer: B. A chunk of text (a word, part of a word or punctuation) the model reads and writes

    Explanation: Tokenizers split text into sub-word pieces. In English a token averages about ¾ of a word, which is why limits and prices are given in tokens.

  5. What is the output?

    DSA · medium

    def f(arr):
        lo, hi = 0, len(arr) - 1
        while lo < hi:
            arr[lo], arr[hi] = arr[hi], arr[lo]
            lo += 1
            hi -= 1
        return arr
    print(f([1, 2, 3, 4, 5]))
    1. [5, 4, 3, 2, 1]
    2. [1, 2, 3, 4, 5]
    3. [5, 2, 3, 4, 1]
    4. [2, 1, 4, 3, 5]

    Answer: A. [5, 4, 3, 2, 1]

    Explanation: Two pointers swap from both ends towards the middle, reversing the array in place in O(n) time and O(1) extra space.

  6. What problem does Retrieval-Augmented Generation (RAG) mainly solve?

    AI & GenAI · medium

    1. Slow GPUs
    2. The model lacks up-to-date or private knowledge, so relevant documents are fetched and added to the prompt
    3. Too many parameters
    4. Tokenisation errors

    Answer: B. The model lacks up-to-date or private knowledge, so relevant documents are fetched and added to the prompt

    Explanation: RAG embeds your documents, retrieves the most relevant chunks for each question and puts them in the context, so answers can use fresh or private data without retraining.

  7. What are embeddings?

    AI & GenAI · medium

    1. Compressed model weights
    2. Dense vectors where similar meanings end up close together
    3. Hidden system prompts
    4. Image thumbnails

    Answer: B. Dense vectors where similar meanings end up close together

    Explanation: An embedding model maps text (or images) to vectors; similarity is measured with cosine similarity or dot product. They power semantic search and RAG.

  8. Why do residual (skip) connections help train very deep networks?

    AI & GenAI · hard

    1. They reduce the number of parameters
    2. They give gradients a direct path backwards, easing vanishing gradients and letting layers learn small corrections
    3. They replace activation functions
    4. They make the network convex

    Answer: B. They give gradients a direct path backwards, easing vanishing gradients and letting layers learn small corrections

    Explanation: With y = x + F(x), the gradient always includes an identity term. ResNets and Transformers both rely on this to go dozens or hundreds of layers deep.

  9. Which statements about RLHF are true? (Select all that apply)

    AI & GenAI · hard

    1. A reward model is trained on human preference comparisons
    2. The policy is optimised (e.g. with PPO) to score highly on that reward model
    3. A KL penalty keeps the policy close to the original model
    4. It replaces pre-training

    Answer: A. A reward model is trained on human preference comparisons; B. The policy is optimised (e.g. with PPO) to score highly on that reward model; C. A KL penalty keeps the policy close to the original model

    Explanation: RLHF comes after pre-training and supervised fine-tuning. The KL term stops the policy drifting into text that games the reward model. DPO is a simpler alternative that skips the explicit reward model.

  10. In scaled dot-product attention, softmax(QKᵀ / √dₖ)·V, why divide by √dₖ?

    AI & GenAI · hard

    1. To normalise V
    2. For large dₖ the dot products grow large, pushing softmax into regions with tiny gradients; scaling keeps their variance about 1
    3. To make attention causal
    4. To reduce memory use

    Answer: B. For large dₖ the dot products grow large, pushing softmax into regions with tiny gradients; scaling keeps their variance about 1

    Explanation: With unit-variance components, q·k has variance dₖ. Dividing by √dₖ keeps the logits moderate so softmax doesn’t saturate.

Play the next Daily Quiz at 4 PM IST