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
96 practiced
Discuss how hash table (Map) resizing affects performance in JavaScript implementations. Cover amortized analysis of insertions, the cost of rehashing spikes, pathological collision scenarios causing O(n) operations, and practical mitigations in UI contexts (preallocation, incremental rehashing, scheduling work during idle time).
EasyTechnical
132 practiced
Describe binary search and its time complexity. Include practical front-end scenarios where binary search is applicable (for example, searching sorted data, finding an insertion point for virtualized lists, or mapping pixel offset to item index). Also discuss typical pitfalls and preconditions required for correctness.
MediumTechnical
94 practiced
Implement a MinHeap class in JavaScript that supports insert(key, priority), extractMin(), and decreaseKey(key, newPriority) efficiently. Explain how you combine the heap array with a Map to provide O(log n) decreaseKey and O(1) lookup of a key's index, and state time/space complexities.
EasyTechnical
126 practiced
Write a JavaScript function that performs a breadth-first traversal of a DOM subtree and returns an array of node tagNames in level order. The implementation should be iterative (avoid recursion) to handle very deep trees without causing stack overflow. State the time and space complexity of your solution.
MediumTechnical
101 practiced
Implement in JavaScript a function longestWithKDistinct(s, k) that returns the length of the longest substring containing at most k distinct characters. Aim for O(n) time and O(k) space. Explain how your sliding-window maintains character counts and adjusts boundaries.

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.