Data Structures Quiz

Grade 11 · Technology · Quiz

Eight questions testing your understanding of arrays, linked lists, stacks, queues, trees, and hash tables.

Questions

  1. What is the time complexity of deleting an element from the middle of an array of n elements?

    1. O(1)
    2. O(log n)
    3. O(n)
    4. 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.

  2. 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.

  3. 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.

  4. 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?

    1. AVL Tree
    2. Red-Black Tree
    3. B-Tree
    4. 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).

  5. 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.

  6. Which data structure is most appropriate for implementing an 'undo' feature in a text editor?

    1. Queue
    2. Stack
    3. Heap
    4. Graph
    Show answer

    Answer: Stack

    Each user action is pushed onto the stack; undoing pops the most recent action — a perfect LIFO use case.

  7. What is the space complexity of a singly linked list with n elements?

    1. O(1)
    2. O(log n)
    3. O(n)
    4. 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.

  8. 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.