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
95 practiced
Design an approximate nearest neighbor (ANN) search component for high-dimensional 512-d embedding vectors used in semantic search. Compare KD-tree, locality-sensitive hashing (LSH), and inverted file with product quantization (IVF+PQ) such as used in FAISS, and explain how you would choose and tune an approach given constraints on latency, recall, and memory for production serving.
EasyTechnical
121 practiced
Explain how dynamic arrays (resizable arrays) implement the append operation in common languages such as Python list or Java ArrayList. Describe the memory layout differences compared to linked lists, explain a geometric resizing strategy such as doubling, derive the amortized time complexity for a sequence of n appends, state the worst case cost for a single append, and discuss memory overhead and fragmentation effects in practice.
MediumTechnical
87 practiced
Implement a UnionFind (disjoint set union) data structure in Python with union by rank and path compression. Provide methods find(x), union(x, y), and connected(x, y). Explain the amortized complexity for m operations on n elements and when this structure is appropriate in ML pipelines such as clustering preprocessing.
EasyTechnical
94 practiced
Explain how a binary heap implements a priority queue. Describe the array-based memory layout, the parent-child index calculations, the algorithms and time complexity for push, pop, and peek, and explain why heapify can be done in O(n) time. Mention why heaps are used in Dijkstra and priority-based scheduling.
MediumTechnical
143 practiced
Design an approximate distinct element counter for estimating the number of unique users from billions of events under a tight memory budget per shard. Explain HyperLogLog conceptually, describe how hash functions, registers, and merging work, and quantify the memory versus accuracy tradeoff for practical register sizes.

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.