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

In a tree, what are sibling nodes?

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

What is a deque (double-ended queue)?

  1. AA structure that allows insertion and removal at both ends
  2. BA queue sorted by priority
  3. CTwo separate queues sharing one array
  4. DA queue that only allows removal at the back
3.Easy

What is the main difference between a static array and a dynamic array?

  1. AA dynamic array can grow by moving to a larger block of memory
  2. BA static array allows slower index access
  3. CA dynamic array stores its elements in linked nodes so it can grow one at a time
  4. DA static array can only store numbers
4.Medium

Why can a binary heap be stored in an array without any pointers?

  1. AAll keys in a heap are equal
  2. BIt is a complete binary tree, so positions follow simple index formulas
  3. CArrays automatically keep the keys in sorted order, so no pointers are needed
  4. DHeaps never contain more than 100 elements
5.Medium

How is a new element inserted into a binary heap?

  1. APlace it at the root and sift it down
  2. BPlace it at the end of the array and sift it up while it violates the heap property
  3. CInsert it at its sorted position by shifting all of the larger elements one place right
  4. DRebuild the whole heap from scratch
6.Medium

Which abstract data type does Dijkstra's algorithm use to choose the next vertex to process?

  1. AA stack
  2. BA FIFO queue
  3. CA set with no ordering
  4. DA min-priority queue
7.Hard

A Bloom filter can answer "is this element in the set?" with:

  1. APossible false positives but no false negatives
  2. BAnswers only for numbers
  3. CExact answers always
  4. DPossible false negatives but no false positives
8.Hard

Why can elements not simply be deleted from a standard Bloom filter by clearing their bits?

  1. ABits in a Bloom filter cannot be changed after creation
  2. BDeleting would increase the false positive rate to 100%
  3. CBloom filters store the full elements, and these cannot be located again once hashed
  4. DThose bits may also belong to other elements, which would cause false negatives

Answer key

  1. 1. A · Nodes that share the same parent
  2. 2. A · A structure that allows insertion and removal at both ends
  3. 3. A · A dynamic array can grow by moving to a larger block of memory
  4. 4. B · It is a complete binary tree, so positions follow simple index formulas
  5. 5. B · Place it at the end of the array and sift it up while it violates the heap property
  6. 6. D · A min-priority queue
  7. 7. A · Possible false positives but no false negatives
  8. 8. D · Those bits may also belong to other elements, which would cause false negatives

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