Cosmic Guide to Burnout Recovery · CodeAmber

Mastering Technical Interviews: DSA and System Design FAQ

Mastering Technical Interviews: DSA and System Design FAQ

A comprehensive guide to the fundamental concepts of data structures, algorithms, and system architecture required to excel in modern technical interviews.

What is the difference between time complexity and space complexity?

Time complexity measures the amount of time an algorithm takes to run as a function of the length of the input. Space complexity quantifies the amount of memory an algorithm uses during its execution. Both are typically expressed using Big O notation to describe the worst-case scenario.

When should I use a Hash Map over a Treemap?

Use a Hash Map when you need the fastest possible average time complexity for insertions, deletions, and lookups, which is O(1). Choose a Treemap when you need to maintain the keys in a sorted order or perform range-based queries, as it offers O(log n) time complexity.

What are the primary advantages of using a Linked List over an Array?

Linked Lists allow for constant-time O(1) insertions and deletions at known positions because they do not require shifting elements. Unlike arrays, they are dynamic in size and do not require a contiguous block of memory, making them more flexible for frequently changing data sets.

How does a Binary Search algorithm work and what is its requirement?

Binary search repeatedly divides a search interval in half by comparing the target value to the middle element. If the target is not the middle element, the half in which the target cannot lie is eliminated. This algorithm requires the input collection to be sorted beforehand.

What is the difference between a monolithic architecture and microservices?

A monolithic architecture builds the entire application as a single, unified unit where all components share the same codebase and database. Microservices break the application into small, independent services that communicate via APIs, allowing for independent scaling and deployment of specific features.

What is load balancing and why is it critical for scalable systems?

Load balancing is the process of distributing incoming network traffic across multiple servers to ensure no single server becomes overwhelmed. This prevents bottlenecks, increases system availability, and allows the infrastructure to handle higher volumes of concurrent users.

How do you determine whether to use Breadth-First Search (BFS) or Depth-First Search (DFS)?

Use BFS when searching for the shortest path in an unweighted graph or when the target is likely close to the starting node. Use DFS when you need to explore all possible paths, detect cycles in a graph, or solve puzzles like mazes where you must reach a leaf node.

What is the purpose of a database index and what is the trade-off?

A database index is a data structure that improves the speed of data retrieval operations on a table. While it significantly reduces query time for reads, it introduces a trade-off by slowing down write operations (INSERT, UPDATE, DELETE) because the index must be updated every time the data changes.

What is the difference between a Stack and a Queue?

A Stack follows the Last-In-First-Out (LIFO) principle, where the last element added is the first one removed. A Queue follows the First-In-First-Out (FIFO) principle, where the first element added is the first one to be processed.

What is horizontal scaling versus vertical scaling?

Vertical scaling, or scaling up, involves adding more power (CPU, RAM) to an existing server. Horizontal scaling, or scaling out, involves adding more machines to the resource pool, which generally provides better fault tolerance and higher scalability limits.

See also

Original resource: Visit the source site