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
95 practiced
You must choose a container for active game entities that are frequently spawned and destroyed mid-frame. Compare using a linked list versus a contiguous array (vector) in terms of insertion/deletion cost, iteration performance, memory overhead, allocation patterns, and cache locality. For a real-time console game where iteration happens every frame, which would you choose and why?
EasyTechnical
84 practiced
Explain why appending elements to a dynamic array (for example std::vector in C++ or List<T> in C#) has amortized O(1) time complexity. Describe a typical growth strategy (e.g., doubling), perform an aggregate/amortized cost analysis for n appends, and relate how this behavior affects a mobile game that performs many small appends during frame-critical asset streaming. Comment on memory overhead and reallocation costs.
MediumTechnical
89 practiced
Implement a trie (prefix tree) interface for autocomplete of in-game chat commands or player names. Provide methods or pseudocode for Insert(word), StartsWith(prefix), and Suggest(prefix, k) that returns up to k suggestions ordered by stored frequency. Use C++ or clear pseudocode and discuss memory usage and compression techniques to reduce footprint on consoles/mobile.
EasyTechnical
92 practiced
Implement an undo/redo system for a simple level editor used by your game. In C++ or C#, provide a class (or pseudocode) supporting: ApplyAction(Action), Undo(), Redo(). Assume Action has Execute() and Unexecute() methods. Explain data structures used, time and space complexity of operations, and strategies to limit memory growth (e.g., checkpoints, delta compression, truncation of history).
HardSystem Design
70 practiced
Design an efficient event timer scheduler for a real-time game server that must handle millions of timers. Compare using a min-heap (priority queue) versus hierarchical timing wheels (or calendar queues) and analyze insertion, cancellation, tick/advance costs, memory overhead, and worst-case behaviors. Recommend a design for a low-latency authoritative server.

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.