Data structures worksheet with answers

Free printable Data structures worksheet: 8 problems from easy to exam level, with an answer key. Print it or save it as a PDF.

For teachers: free to print, copy and use in class. Every new worksheet has new values and its own answer key. A link to ExamProblems on your course page is appreciated.

Name: ____________________   Date: ____________

1.Easy

Which data structure works on the principle "first in, first out"?

  1. AHeap
  2. BBinary tree
  3. CQueue
  4. DStack
2.Easy

In a tree, what are sibling nodes?

  1. AA node and its parent
  2. BNodes that have no children
  3. CNodes that share the same parent
  4. DNodes at the same depth in different subtrees
3.Easy

In a hash table, what is a collision?

  1. ATwo equal keys are stored twice
  2. BTwo different keys map to the same index
  3. CA key cannot be hashed at all
  4. DThe table runs out of memory
4.Medium

What is the purpose of a sentinel (dummy) node in a linked list?

  1. ATo make the list sorted
  2. BTo store the number of elements
  3. CTo simplify code by removing special cases at the head or tail
  4. DTo prevent the list from growing beyond a fixed maximum number of nodes
5.Medium

In a hash table using open addressing, what is the maximum possible load factor?

  1. A0.5
  2. B2
  3. C1
  4. DThere is no maximum
6.Medium

The keys 50, 30, 70, 20, 40 are inserted in this order into an empty binary search tree. What is the left child of 30?

  1. A20
  2. B50
  3. C70
  4. D40
7.Hard

An AVL node is unbalanced because its left child's right subtree became too tall (left-right case). Which fix is applied?

  1. AA right rotation at the left child, then a left rotation at the node
  2. BA left rotation at the left child, then a right rotation at the node
  3. CA single right rotation at the node
  4. DA single left rotation at the node
8.Hard

Which property keeps every B-tree perfectly balanced?

  1. AEach node stores one key
  2. BEvery node has exactly two children
  3. CThe keys are stored only in the root
  4. DAll leaves are at the same depth

Answer key

  1. 1. C · Queue
  2. 2. C · Nodes that share the same parent
  3. 3. B · Two different keys map to the same index
  4. 4. C · To simplify code by removing special cases at the head or tail
  5. 5. C · 1
  6. 6. A · 20
  7. 7. B · A left rotation at the left child, then a right rotation at the node
  8. 8. D · All leaves are at the same depth

Full step-by-step solutions: practise this topic on examproblems.com.