InterviewStack.io LogoInterviewStack.io

Data Structures and Complexity Questions

Comprehensive coverage of fundamental data structures, their operations, implementation trade offs, and algorithmic uses. Candidates should know arrays and strings including dynamic array amortized behavior and memory layout differences, linked lists, stacks, queues, hash tables and collision handling, sets, trees including binary search trees and balanced trees, tries, heaps as priority queues, and graph representations such as adjacency lists and adjacency matrices. Understand typical operations and costs for access, insertion, deletion, lookup, and traversal and be able to analyze asymptotic time and auxiliary space complexity using Big O notation including constant, logarithmic, linear, linearithmic, quadratic, and exponential classes as well as average case, worst case, and amortized behaviors. Be able to read code or pseudocode and derive time and space complexity, identify performance bottlenecks, and propose alternative data structures or algorithmic approaches to improve performance. Know common algorithmic patterns that interact with these structures such as traversal strategies, searching and sorting, two pointer and sliding window techniques, divide and conquer, recursion, dynamic programming, greedy methods, and priority processing, and when to combine structures for efficiency for example using a heap with a hash map for index tracking. Implementation focused skills include writing or partially implementing core operations, discussing language specific considerations such as contiguous versus non contiguous memory and pointer or manual memory management when applicable, and explaining space time trade offs and cache or memory behavior. Interview expectations vary by level from selecting and implementing appropriate structures for routine problems at junior levels to optimizing naive solutions, designing custom structures for constraints, and reasoning about amortized, average case, and concurrency implications at senior levels.

HardSystem Design
150 practiced
Design a lock manager for distributed transactions in a multi-shard data system. Describe how you would implement locking primitives, detect deadlocks (for example using a wait-for graph), and analyze the complexity of deadlock detection and resolution. Discuss scalability considerations and how to avoid global coordination where possible.
HardSystem Design
75 practiced
You are designing a memory-efficient radix tree (compressed trie) to store 50 million short strings (avg length 16) under a 64 GB memory limit. Propose a node layout (fields and types), explain how to pack data to reduce overhead per node, describe how to handle variable-length edges, and discuss lookup time and memory trade-offs.
MediumTechnical
86 practiced
Design a system to track approximate distinct counts (unique users) per day across 1000+ partitions using limited memory. Compare HyperLogLog and exact counting alternatives, explain error bounds, memory trade-offs, how to merge sketches across partitions, and the complexity implications for real-time dashboards.
HardTechnical
81 practiced
You must compute strongly connected components (SCCs) in a very large directed graph stored across multiple machines. Compare algorithms (Tarjan, Kosaraju) for single-machine use and outline a distributed approach (for example Pregel/Bulk Synchronous Parallel) for SCC detection. Discuss data representation, communication cost, and complexity.
EasyTechnical
88 practiced
Compare adjacency list and adjacency matrix graph representations. For a graph with n vertices and m edges, give space and time complexity for common operations (iterate neighbors, check edge existence). For a directed web-graph with n=100M and m=10B, which representation would you choose and why?

Unlock Full Question Bank

Get access to hundreds of Data Structures and Complexity interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.