Daily Coding Quiz: Friday, 6 November 2026
All 10 coding questions with answers and explanations. 0 players took part.
What is the maximum number of nodes in a binary tree of height 3 (a single root has height 0)?
DSA · easy
- 7
- 8
- 15
- 16
Answer: C. 15
Explanation: Levels 0 to 3 hold 1 + 2 + 4 + 8 = 15 nodes, i.e. 2^(h+1) − 1.
What is the average time complexity of looking up a key in a hash table?
DSA · easy
- O(1)
- O(log n)
- O(n)
- 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).
Which activation function outputs max(0, x)?
AI & GenAI · easy
- Sigmoid
- Tanh
- ReLU
- 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.
In an LLM, what is a “token”?
AI & GenAI · easy
- Always one whole word
- A chunk of text (a word, part of a word or punctuation) the model reads and writes
- An API key
- 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.
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]))- [5, 4, 3, 2, 1]
- [1, 2, 3, 4, 5]
- [5, 2, 3, 4, 1]
- [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.
What problem does Retrieval-Augmented Generation (RAG) mainly solve?
AI & GenAI · medium
- Slow GPUs
- The model lacks up-to-date or private knowledge, so relevant documents are fetched and added to the prompt
- Too many parameters
- 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.
What are embeddings?
AI & GenAI · medium
- Compressed model weights
- Dense vectors where similar meanings end up close together
- Hidden system prompts
- 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.
Why do residual (skip) connections help train very deep networks?
AI & GenAI · hard
- They reduce the number of parameters
- They give gradients a direct path backwards, easing vanishing gradients and letting layers learn small corrections
- They replace activation functions
- 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.
Which statements about RLHF are true? (Select all that apply)
AI & GenAI · hard
- A reward model is trained on human preference comparisons
- The policy is optimised (e.g. with PPO) to score highly on that reward model
- A KL penalty keeps the policy close to the original model
- 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.
In scaled dot-product attention, softmax(QKᵀ / √dₖ)·V, why divide by √dₖ?
AI & GenAI · hard
- To normalise V
- For large dₖ the dot products grow large, pushing softmax into regions with tiny gradients; scaling keeps their variance about 1
- To make attention causal
- 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.