CodeSignal Technical Assessment Domain-Specific Knowledges 2 — Questions and Answers
Question 1: In a REST API, which HTTP status code indicates that the client's request was syntactically correct but semantically invalid (e.g., a business rule violation)?
- 400 Bad Request
- 422 Unprocessable Entity (Correct answer)
- 409 Conflict
- 412 Precondition Failed
Correct answer: 422 Unprocessable Entity
422 Unprocessable Entity is used when the request is well-formed but contains semantic errors that prevent processing.
Question 2: Which SQL isolation level prevents dirty reads but still allows non-repeatable reads?
- Read Uncommitted
- Serializable
- Read Committed (Correct answer)
- Repeatable Read
Correct answer: Read Committed
Read Committed prevents reading uncommitted (dirty) data but allows another transaction to modify rows between two reads in the same transaction.
Question 3: In object-oriented design, the Liskov Substitution Principle states that:
- A class should have only one reason to change
- Objects of a superclass should be replaceable with objects of its subclasses without breaking correctness (Correct answer)
- High-level modules should not depend on low-level modules
- A class should not be forced to implement interfaces it does not use
Correct answer: Objects of a superclass should be replaceable with objects of its subclasses without breaking correctness
LSP requires that subclasses honor the behavioral contracts of their parent classes so callers can rely on polymorphism safely.
Question 4: Which data structure offers O(1) average-case insertion and lookup but O(n) worst-case due to hash collisions?
- AVL Tree
- Hash Table (Correct answer)
- Sorted Array
- Skip List
Correct answer: Hash Table
Hash tables achieve O(1) average operations but degrade to O(n) when all keys hash to the same bucket.
Question 5: In Git, what does a 'detached HEAD' state mean?
- The HEAD pointer references a specific commit rather than a branch (Correct answer)
- The remote branch has been deleted
- The local repo has merge conflicts
- HEAD points to an orphan branch with no commits
Correct answer: The HEAD pointer references a specific commit rather than a branch
Detached HEAD means HEAD points directly to a commit SHA instead of a named branch ref, so new commits won't belong to any branch.
Question 6: Which Big-O complexity describes inserting an element at the beginning of a singly linked list?
- O(n)
- O(log n)
- O(1) (Correct answer)
- O(n log n)
Correct answer: O(1)
Inserting at the head of a singly linked list requires only updating the head pointer and the new node's next pointer, both constant-time operations.
Question 7: In a microservices architecture, the Saga pattern is primarily used to:
- Cache inter-service responses for performance
- Manage distributed transactions across multiple services without two-phase commit (Correct answer)
- Load-balance requests between service replicas
- Encrypt messages passed over the service mesh
Correct answer: Manage distributed transactions across multiple services without two-phase commit
The Saga pattern coordinates a sequence of local transactions across services, using compensating transactions to undo changes on failure.
In a REST API, which HTTP status code indicates that the client's request was syntactically correct but semantically invalid (e.g., a business rule violation)?