Daily Coding Quiz: Friday, 20 November 2026
All 10 coding questions with answers and explanations. 0 players took part.
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 does a higher “temperature” do when sampling from an LLM?
AI & GenAI · easy
- Makes answers more deterministic
- Makes output more random and varied
- Makes the model faster
- Increases the context window
Answer: B. Makes output more random and varied
Explanation: Temperature divides the logits before softmax. Above 1 flattens the distribution (more surprising tokens); near 0 almost always picks the top token.
What is the time complexity of this code?
DSA · medium
i = 1 while i < n: i *= 2- O(n)
- O(log n)
- O(√n)
- O(n log n)
Answer: B. O(log n)
Explanation: i doubles each iteration (1, 2, 4, …), so it passes n after about log₂ n iterations.
Topological sort is possible only on which kind of graph?
DSA · medium
- Any undirected graph
- A directed acyclic graph (DAG)
- A complete graph
- A weighted graph
Answer: B. A directed acyclic graph (DAG)
Explanation: A topological order puts every edge u→v with u before v. A cycle makes that impossible, so the graph must be a DAG.
What is printed?
DSA · medium
from collections import deque q = deque([1, 2, 3]) q.append(4) q.popleft() q.appendleft(0) print(list(q))- [0, 2, 3, 4]
- [0, 1, 2, 3]
- [2, 3, 4, 0]
- [1, 2, 3, 4]
Answer: A. [0, 2, 3, 4]
Explanation: append(4) → [1,2,3,4]; popleft() removes 1 → [2,3,4]; appendleft(0) → [0,2,3,4].
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.
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.
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.