Daily Coding Quiz: Thursday, 5 November 2026
All 10 coding questions with answers and explanations. 0 players took part.
Inserting a new node at the head of a singly linked list takes:
DSA · easy
- O(1)
- O(log n)
- O(n)
- O(n log n)
Answer: A. O(1)
Explanation: Point the new node at the current head and make it the head: a constant number of pointer updates.
Which technique is the classic way to check if a string of brackets like "({[]})" is balanced?
DSA · easy
- Two pointers
- A stack
- Binary search
- Sorting
Answer: B. A stack
Explanation: Push each opening bracket; on a closing bracket, the top of the stack must be its match. Balanced if the stack ends empty.
What is the worst-case time complexity of linear search?
DSA · easy
- O(1)
- O(log n)
- O(n)
- O(n²)
Answer: C. O(n)
Explanation: If the item is last or missing, every one of the n elements is checked.
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 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.
Which array is a valid min-heap (array form, children of i at 2i+1 and 2i+2)?
DSA · medium
- [1, 3, 2, 7, 4, 5]
- [1, 5, 2, 3, 6, 4]
- [2, 1, 3, 4, 5, 6]
- [1, 3, 2, 7, 4, 1]
Answer: A. [1, 3, 2, 7, 4, 5]
Explanation: In [1,3,2,7,4,5] every parent is ≤ its children (1≤3,2; 3≤7,4; 2≤5). In the second, 5 > 3; in the third, 2 > 1; in the fourth, 2 > 1 at index 5.
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].
A segment tree over n elements supports range-sum queries and point updates in:
DSA · hard
- O(1) and O(n)
- O(log n) each
- O(√n) each
- O(n) and O(1)
Answer: B. O(log n) each
Explanation: The tree has height O(log n). A query combines O(log n) nodes, and an update changes one leaf and its O(log n) ancestors.
What is printed?
DSA · hard
def lis(a): import bisect tails = [] for x in a: i = bisect.bisect_left(tails, x) if i == len(tails): tails.append(x) else: tails[i] = x return len(tails) print(lis([10, 9, 2, 5, 3, 7, 101, 18]))- 3
- 4
- 5
- 8
Answer: B. 4
Explanation: This is the O(n log n) Longest Increasing Subsequence. One LIS is 2, 3, 7, 18 (or 2, 5, 7, 101), length 4.
Which algorithm can find shortest paths when some edge weights are negative (but there is no negative cycle), and also detect a negative cycle?
DSA · hard
- Dijkstra’s
- Bellman–Ford
- Prim’s
- BFS
Answer: B. Bellman–Ford
Explanation: Bellman–Ford relaxes every edge V−1 times. If a V-th pass still improves a distance, there is a negative cycle. Dijkstra’s can give wrong answers with negative edges.