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
82 practiced
Compare arrays and singly linked lists focusing on memory layout, typical mobile implementations (Swift Array, Java/Kotlin ArrayList, and a simple linked list), and operation costs. For each operation (index-access, prepend, append, insert-middle, delete-middle, traversal) state Big-O for worst/average/amortized where applicable. Explain practical mobile implications: cache locality, allocation frequency, ARC/GC pressure, battery/CPU impact, and when you would prefer one over the other in an Android or iOS app.
EasyTechnical
76 practiced
In Swift, implement an in-place function to reverse a singly linked list. Define a minimal ListNode class/struct and implement:
func reverse(_ head: ListNode?) -> ListNode?
Return the new head. Explain time and space complexity and any ARC (reference count) implications when nodes are ref-counted on iOS.
MediumSystem Design
91 practiced
Design a data structure to support a reliable, deduplicated offline request queue for a mobile app that must enqueue operations while offline and sync later. Requirements: keep order (first-in-first-out for unique keys), deduplicate by operation key (e.g., updates to same entity), persist across app restarts, and provide O(1) enqueue and reasonable dequeue cost. Describe in-memory and on-disk structures, eviction policies, and how to bound storage usage.
HardSystem Design
70 practiced
Explain how you would implement offline-first collaborative notes on mobile using CRDTs. Choose appropriate CRDT types for sequence/text (e.g., RGA, Logoot, Yjs-like models), describe on-device data structures to store operations compactly, on-disk compaction and snapshotting strategies, merge algorithms and their complexity, and how to bound memory usage while preserving convergence guarantees.
EasyTechnical
91 practiced
Explain how Breadth-First Search (BFS) works on graphs represented with adjacency lists. Provide BFS time and auxiliary space complexity (worst case). Why is adjacency list preferred over adjacency matrix for sparse graphs on mobile devices? Mention iterative vs recursive implementations and mobile-specific considerations like memory footprint and traversal locality.

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.