Arrays, linked lists, stacks, queues, trees, and hash tables with their core operations and typical use cases.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What is an array?
- A contiguous block of memory storing elements of the same type, accessed by index.
- Time complexity to access element at index i in an array?
- O(1) constant time, direct access by memory address.
- Time complexity to insert at the beginning of an array?
- O(n) linear time, requires shifting all existing elements.
- What is a limitation of static arrays?
- Fixed size that cannot be changed after creation without reallocating.
- What is a linked list?
- A collection of nodes where each node contains data and a reference to the next node.
- Time complexity to access the nth element in a singly linked list?
- O(n) linear time, must traverse from head node.
- Time complexity to insert after a known node in a linked list?
- O(1) constant time, only update references.
- What is a node?
- An element in a linked list containing data and one or more references to other nodes.
- Difference between singly and doubly linked lists?
- Singly has one reference per node (next only), doubly has two (next and previous).
- Name one advantage of linked lists over arrays.
- Efficient insertion and deletion at any known position (O(1)) without shifting.
- What is a circular linked list?
- A linked list where the last node points back to the first node.
- What is a stack?
- A linear data structure where insertion and deletion occur at the same end (top).
- What does LIFO stand for?
- Last In, First Out - the last element added is the first one removed.
- The two primary operations on a stack?
- Push (add to top) and pop (remove from top).
- Time complexity of push and pop on a stack?
- O(1) constant time, both modify only the top.