Data Structures Quiz
Grade 11 · Technology · Quiz
Eight questions testing your understanding of arrays, linked lists, stacks, queues, trees, and hash tables.
Questions
What is the time complexity of deleting an element from the middle of an array of n elements?
- O(1)
- O(log n)
- O(n)
- O(n^2)
Show answer
Answer: O(n)
Deleting from the middle requires shifting all elements after the deleted position one index to the left, which takes O(n) time in the worst case.
A deque (double-ended queue) allows insertion and deletion at both ends.
Show answer
Answer: True
A deque supports push_front, push_back, pop_front, and pop_back — all in O(1) — which is what distinguishes it from a plain stack or queue.
In a max-heap, the root node always contains the ________ value in the collection.
Show answer
Answer: largest
By the max-heap property, every parent node is greater than or equal to its children, so the maximum value bubbles up to the root.
Which self-balancing BST variant guarantees O(log n) operations by ensuring no path from root to leaf is more than twice as long as any other?
- AVL Tree
- Red-Black Tree
- B-Tree
- Splay Tree
Show answer
Answer: Red-Black Tree
Red-Black trees enforce a coloring invariant that guarantees no path is more than twice as long as the shortest path, bounding height at O(log n).
A hash table with open addressing resolves collisions by storing the colliding element in the next available slot within the same array.
Show answer
Answer: True
Open addressing (linear probing, quadratic probing, double hashing) probes successive slots in the array itself rather than using a linked chain.
Which data structure is most appropriate for implementing an 'undo' feature in a text editor?
- Queue
- Stack
- Heap
- Graph
Show answer
Answer: Stack
Each user action is pushed onto the stack; undoing pops the most recent action — a perfect LIFO use case.
What is the space complexity of a singly linked list with n elements?
- O(1)
- O(log n)
- O(n)
- O(n^2)
Show answer
Answer: O(n)
Each of the n elements requires a node object (value + pointer), so total space scales linearly with the number of elements.
The process of ensuring a BST remains height-balanced after insertions or deletions is called ________.
Show answer
Answer: rebalancing
Rebalancing — achieved through rotations in AVL and Red-Black trees — restores the height invariant after structural changes, preserving O(log n) guarantees.
Get a personalized course on Data Structures built around your child.