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.

HardTechnical
0 practiced
A third-party library uses singly linked lists for large in-memory queues and you observe latency spikes. Explain how contiguous memory (arrays) versus non-contiguous memory (linked lists) affects CPU cache behavior, branch prediction, and traversal latency. Propose alternative data structures (chunked arrays, deque, slab allocator) and analyze complexity and trade-offs for SRE workloads.
MediumTechnical
0 practiced
Implement disjoint-set union (union-find) in Python with path compression and union by rank/size. Provide find(x) and union(x,y) operations, analyze their amortized time complexity, and describe a concrete SRE use case such as grouping related incidents or correlated failures.
MediumTechnical
0 practiced
Implement a class in Python that supports add(num) and get_median() for a stream of integers. Use two heaps (a max-heap for lower half and a min-heap for upper half) to achieve O(log n) insert and O(1) median retrieval. Provide code and discuss memory and performance considerations when used for per-service latency tracking in SRE.
MediumSystem Design
0 practiced
You must design an in-memory time-series buffer for recent N minutes of metrics per host, supporting append(timestamp, value) and range queries (start, end). Compare ring-buffer, chunked arrays, and per-series circular logs in terms of read/write complexity, memory usage, garbage-collection/fragmentation effects, and cache behavior. State which you would pick for an SRE observability agent and why.
MediumTechnical
0 practiced
Design a per-user sliding-window rate limiter for an API handling 100k requests/sec and millions of users. Requirement: allow(user_id, timestamp) returns true if the user made fewer than 100 requests in the last 60 seconds. Propose data structures, sharding strategy, and approximate alternatives to reduce memory while maintaining low latency; analyze lookup and update complexity.

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.