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.

MediumTechnical
0 practiced
Implement a least-recently-used (LRU) cache in Python with O(1) get(key) and put(key, value) operations. The cache should have a fixed capacity and evict the least-recently-used item when full. Provide the class signature and explain your choice of underlying data structures and complexity.
MediumTechnical
0 practiced
Describe the Count-Min Sketch data structure and how it supports approximate frequency counting in data streams. Explain the update and query operations, how to choose width and depth parameters based on desired error and confidence, and memory/time complexity trade-offs.
MediumTechnical
0 practiced
Implement a union-find (disjoint-set) structure in your preferred language that supports union and find with union by rank and path compression. Include complexity analysis and describe one scenario in data engineering (for example, grouping related events) where you would use it.
MediumTechnical
0 practiced
Design a data structure that supports the following streaming operations: add(num) and get_median(), where add receives a number and get_median returns the median of all numbers seen so far. The structure should be efficient in time and memory for large streams. Describe your approach, operations' time complexity, and memory usage.
EasyTechnical
0 practiced
Explain how dynamic arrays (for example Java's ArrayList or Python's list) achieve amortized O(1) time for append operations. Describe the doubling (or growth-factor) strategy, what happens during reallocation/copy, how to compute amortized cost over a sequence of n appends, and discuss memory usage trade-offs and implications in languages without automatic garbage collection.

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.