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.

EasyTechnical
140 practiced
Explain the amortized time complexity for append (push_back) operations in a dynamic array (resizable array) that grows by doubling its capacity when full. In your answer: (1) state the worst-case time of a single append, (2) derive the amortized time per append over n appends using an aggregate or accounting argument, and (3) discuss what changes if the array grows by a fixed additive amount instead of by a multiplicative factor.
EasyTechnical
96 practiced
Describe the trie (prefix tree) data structure: node layout, insertion, search, and prefix lookup complexities. For a backend autocomplete service storing English words with frequency counts, explain trade-offs between a standard trie, a compressed (radix) trie, and storing sorted words in an array with binary search. How would you return top-k suggestions efficiently?
MediumTechnical
80 practiced
Design an in-memory per-API-key rate limiter that enforces a rolling window limit of R requests per T seconds. Target workload: 100k active keys, 1M requests/minute aggregate. Describe the data structures, memory estimate per key, time complexity for checking/recording a request, pruning inactive keys, and a distributed option using Redis. Explain trade-offs between exact and approximate approaches.
HardSystem Design
84 practiced
A backend stores time-series metrics with heavy appends and frequent range queries. Compare using a B-tree/B+tree index vs an LSM-tree (log-structured merge tree). Discuss write/read complexities, compaction costs, write amplification, read amplification, and Bloom filters. Which would you choose for high-ingest low-latency range queries and why?
EasyTechnical
99 practiced
Explain the following asymptotic time complexity classes and give one concrete algorithm or operation example for each: O(1), O(log n), O(n), O(n log n), O(n^2), and O(2^n). For each example say whether the complexity is typically worst-case, average-case, or amortized 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.