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 have no children
  2. BNodes that share the same parent
  3. CNodes at the same depth in different subtrees
  4. DA node and its parent
2.Easy

What defines a binary tree?

  1. AEvery node has at most two children
  2. BEvery node stores a binary number
  3. CEvery node has exactly two children
  4. DThe tree has exactly two levels
3.Easy

In a singly linked list, each node contains:

  1. AOnly data
  2. BData and references to all other nodes
  3. CData and an index
  4. DData and a reference to the next node
4.Medium

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

  1. A1
  2. B2
  3. CThere is no maximum
  4. D0.5
5.Medium

A circular buffer (ring buffer) is commonly used to implement:

  1. AA binary search tree
  2. BA hash function
  3. CA fixed-size queue
  4. DA graph traversal
6.Medium

How long does a search for a word of length L take in a trie with a fixed alphabet?

  1. AO(L), independent of how many words are stored
  2. BO(L × n)
  3. CO(n), where n is the number of words
  4. DO(log n), where n is the number of words
7.Hard

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

  1. AAnswers only for numbers
  2. BPossible false positives but no false negatives
  3. CPossible false negatives but no false positives
  4. DExact answers always
8.Hard

How long does it take to search for an arbitrary key in a binary min-heap of n elements?

  1. AO(log log n)
  2. BO(1)
  3. CO(log n)
  4. DO(n)

Answer key

  1. 1. B · Nodes that share the same parent
  2. 2. A · Every node has at most two children
  3. 3. D · Data and a reference to the next node
  4. 4. A · 1
  5. 5. C · A fixed-size queue
  6. 6. A · O(L), independent of how many words are stored
  7. 7. B · Possible false positives but no false negatives
  8. 8. D · O(n)

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