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
90 practiced
Explain common collision-resolution strategies for hash tables used in backend services: separate chaining, open addressing (linear probing, quadratic probing), and double hashing. For each approach describe average-case and worst-case time for lookup/insert/delete, memory overhead, cache behavior, and practical considerations when handling millions of keys.
EasyTechnical
71 practiced
Explain the conceptual difference between a set and a map/dictionary. Give three backend use cases where a set is the better choice and three where a map is necessary. Discuss implementation variants (hash-set, tree-set) and when you might use a Bloom filter as an approximate set.
MediumTechnical
101 practiced
Given the following pseudocode, derive a tight asymptotic time complexity (Theta notation) as n grows:
for i = 1 to n: j = i while j <= n: j = j * 2
Explain your steps and reasoning. How does the result change if j is multiplied by 3 each iteration instead of 2?
EasyTechnical
70 practiced
Compare arrays (contiguous memory) and singly-linked lists (node-based) for the following backend scenarios: (a) frequent indexed reads by position; (b) frequent insertions/removals in the middle given a pointer; (c) iterating over all elements to compute aggregates. For each scenario state typical time complexities for access/insertion/deletion and discuss memory layout, pointer overhead, cache locality, and practical trade-offs in garbage-collected vs manual-memory environments.
HardTechnical
73 practiced
Prove that append operations on a dynamic array that doubles capacity when full have amortized O(1) time per append. Provide an aggregate or accounting proof and compute an upper bound on the amortized number of element copies per insertion when starting from capacity 1. Also discuss how the bound changes for a growth factor c>1 or for additive growth.

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.