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
Design a lock-free bounded queue for producer-consumer workloads (C++ or Java). Describe the ring-buffer design, use of atomic head and tail counters, how to detect full/empty conditions correctly, how to avoid the ABA problem when reusing slots, and memory-reclamation techniques such as hazard pointers or epoch-based reclamation.
HardTechnical
0 practiced
Implement or outline a thread-safe LRU cache in Python that supports get and put with O(1) operations. Discuss the synchronization strategy given Python's GIL, where locks are required for compound updates, and alternatives such as multiprocessing.Manager, external caches (Redis/memcached), or writing a C extension for higher throughput. Explain expected performance trade-offs.
MediumTechnical
0 practiced
Explain how a Bloom filter works, derive the approximate false positive probability p as a function of bit array size m, number of hash functions k, and number of inserted elements n. Compute m and k required to store n = 1,000,000 items with target false positive rate p = 0.01. Discuss trade-offs and how counting Bloom filters allow element deletions.
MediumTechnical
0 practiced
Given an array of integers and integer k, write a Python function that returns the length of the longest contiguous subarray containing at most k distinct integers. Your solution should run in O(n) time and O(k) space. Provide code, explain algorithm (sliding window + hashmap) and cover edge cases.
HardSystem Design
0 practiced
For joining two large tables that do not fit in memory, compare hash join and sort-merge join. For each algorithm describe required data structures, external IO patterns, buffer management (how to partition and spill), handling data skew, and parallelization strategies. For typical data engineering feature joins, which 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.