Software Engineering Trivia 5 — Questions and Answers
Question 1: Which algorithm traversal visits all nodes at the current depth level before moving to the next level?
- Depth-First Search (DFS)
- Breadth-First Search (BFS) (Correct answer)
- Inorder traversal
- Postorder traversal
Correct answer: Breadth-First Search (BFS)
BFS uses a queue to explore all neighbors at the present depth prior to moving on to nodes at the next depth level.
Question 2: What is 'technical debt' in software engineering?
- The cost of purchasing developer tools and licenses
- The implied cost of rework caused by choosing a quick, easy solution instead of a better but longer-term approach (Correct answer)
- Outstanding bug reports in a project backlog
- Dependencies on deprecated third-party libraries
Correct answer: The implied cost of rework caused by choosing a quick, easy solution instead of a better but longer-term approach
Technical debt is the future cost of maintaining or reworking expedient but suboptimal code, analogous to financial debt that accrues interest.
Question 3: In the context of microservices, what is an API gateway?
- A database that stores API credentials
- A single entry point that routes client requests to appropriate backend microservices (Correct answer)
- A tool for auto-generating API documentation
- A load balancer that distributes traffic within a single service
Correct answer: A single entry point that routes client requests to appropriate backend microservices
An API gateway acts as a reverse proxy that aggregates requests, handles cross-cutting concerns like auth and rate limiting, and routes to downstream services.
Question 4: What does the CAP theorem state about distributed systems?
- A distributed system can guarantee Consistency, Availability, and Partition tolerance simultaneously
- A distributed system can guarantee at most two of: Consistency, Availability, and Partition tolerance (Correct answer)
- Consistency is always sacrificed when network partitions occur
- Availability and Partition tolerance cannot coexist in the same system
Correct answer: A distributed system can guarantee at most two of: Consistency, Availability, and Partition tolerance
The CAP theorem (Brewer's theorem) states that a distributed system can provide at most two of the three guarantees at the same time.
Question 5: Which software testing technique tests the internal workings and code paths of a system, requiring knowledge of the source code?
- Black-box testing
- Grey-box testing
- White-box testing (Correct answer)
- Smoke testing
Correct answer: White-box testing
White-box (or clear-box) testing exercises specific code paths, branches, and conditions with full knowledge of the implementation.
Question 6: What is the purpose of the 'Dependency Inversion Principle' in SOLID design?
- To prevent circular dependencies between modules
- To ensure high-level modules depend on abstractions, not on low-level concrete implementations (Correct answer)
- To inject dependencies automatically using a framework
- To invert the order in which constructors are called
Correct answer: To ensure high-level modules depend on abstractions, not on low-level concrete implementations
DIP decouples high-level policy from low-level details by having both depend on shared abstractions, making the system easier to test and extend.
Question 7: In asymptotic analysis, what does O(1) space complexity mean for an algorithm?
- The algorithm uses no memory at all
- The algorithm's memory usage is constant regardless of input size (Correct answer)
- The algorithm runs in constant time
- The algorithm allocates exactly one variable
Correct answer: The algorithm's memory usage is constant regardless of input size
O(1) space complexity means the additional memory the algorithm requires does not grow with the size of the input.
Which algorithm traversal visits all nodes at the current depth level before moving to the next level?