Data Structures: Arrays, Lists, Stacks, Queues, Hash Maps
Interview-ready DS basics — operations, complexities, and when to pick each structure.
12 cards· by GuruOwl
Make a deck like this from your own PDF — free.
Try it- 01Array access by index time complexity?O(1) random access (contiguous memory).arrays
- 02Array insert/delete in the middle complexity (typical dynamic array)?O(n) — elements must shift.arrays
- 03Singly linked list: access k-th element complexity?O(n) — must traverse from the head.lists
- 04Linked list insert/delete at known node (with pointer) complexity?O(1) pointer updates (singly list delete needs predecessor).lists
- 05Stack operations and complexity?Push/pop/peek amortized O(1); LIFO order.stack
- 06Queue operations and complexity?Enqueue/dequeue O(1) with proper ends; FIFO order.queue
- 07Hash map average lookup/insert/delete?Average O(1); worst O(n) with collisions/degeneracy.hashmap
- 08What is a good hash function property?Uniform distribution of keys into buckets to minimize collisions.hashmap
- 09Collision resolution: chaining vs open addressing?Chaining: linked lists per bucket. Open addressing: probe for next empty slot.hashmap
- 10When prefer a hash map over an array?When keys are sparse/non-integer or you need fast key-based lookup without sorting.choice
- 11Deque supports what?Insert/delete at both front and back efficiently (double-ended queue).queue
- 12Amortized O(1) append in dynamic arrays — how?Grow capacity geometrically (e.g., ×2) so resizes are rare; average cost per append is O(1).arrays