CodeSignal Technical Assessment Domain-Specific Knowledges 3 — Questions and Answers
Question 1: What is the primary advantage of using an index on a database column?
- Reduces disk storage for the table
- Speeds up SELECT queries at the cost of slower writes (Correct answer)
- Enforces uniqueness by default
- Automatically partitions the table for parallel queries
Correct answer: Speeds up SELECT queries at the cost of slower writes
Indexes create auxiliary data structures that accelerate reads but must be maintained on every insert, update, or delete.
Question 2: In JavaScript, what does the event loop's 'microtask queue' hold, and when does it drain?
- setTimeout callbacks; after each macrotask
- Promise callbacks (.then/.catch); after the current task completes, before the next macrotask (Correct answer)
- DOM event listeners; at the start of each frame
- WebWorker messages; continuously in a background thread
Correct answer: Promise callbacks (.then/.catch); after the current task completes, before the next macrotask
Microtasks (Promise continuations, queueMicrotask) drain completely after each macrotask and before the next macrotask begins.
Question 3: Which TCP mechanism prevents a fast sender from overwhelming a slow receiver?
- Nagle's algorithm
- Flow control via the receive window (Correct answer)
- Congestion control via CWND
- SYN cookies
Correct answer: Flow control via the receive window
TCP flow control uses the receiver-advertised window size (rwnd) to limit how much data the sender can have in-flight at once.
Question 4: In Python, what is the time complexity of checking whether an element exists in a set?
- O(n)
- O(log n)
- O(1) average (Correct answer)
- O(n log n)
Correct answer: O(1) average
Python sets are implemented as hash tables, so membership tests are O(1) on average, O(n) in the degenerate collision case.
Question 5: Which design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime?
- Observer
- Template Method
- Strategy (Correct answer)
- Chain of Responsibility
Correct answer: Strategy
The Strategy pattern lets you select an algorithm at runtime by programming to an interface rather than a concrete class.
Question 6: What is 'eventual consistency' in distributed systems?
- All nodes see every write within a fixed time bound
- Given no new writes, all replicas will converge to the same value over time (Correct answer)
- A transaction is committed only after a quorum of nodes agrees
- Reads always return the most recent committed write
Correct answer: Given no new writes, all replicas will converge to the same value over time
Eventual consistency guarantees convergence in the absence of further updates but does not specify when or impose a strict time bound.
Question 7: In React, what triggers a component to re-render?
- Any variable assignment inside the component function
- Changes to state or props, or a parent re-render (Correct answer)
- DOM mutations triggered by the browser
- Only explicit calls to ReactDOM.render()
Correct answer: Changes to state or props, or a parent re-render
React schedules re-renders when setState is called, when received props change, or when the parent component re-renders (unless memoized).
What is the primary advantage of using an index on a database column?