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

Which operation is slow in an array but fast at the head of a linked list?

  1. AAccessing the 5th element
  2. BFinding the length of a fixed array
  3. CInserting at the beginning
  4. DReading the last element by index
3.Easy

In a singly linked list, what does the next pointer of the last node contain?

  1. AThe address of the first node
  2. BNull (no node)
  3. CThe address of the previous node
  4. DThe number of nodes in the list
4.Medium

A node in a binary search tree has a right subtree. Where is its in-order successor?

  1. AIts parent, always
  2. BThe rightmost node of its left subtree
  3. CThe leftmost node of its right subtree
  4. DIts right child, always
5.Medium

Which collision resolution method stores colliding keys in a list at the same bucket?

  1. AQuadratic probing
  2. BLinear probing
  3. CSeparate chaining
  4. DDouble hashing
6.Medium

How long does it take to check whether the edge (u, v) exists using an adjacency matrix?

  1. AO(log V)
  2. BO(1)
  3. CO(V)
  4. DO(E)
7.Hard

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

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

Which pair of traversals always determines a unique binary tree with distinct keys?

  1. ALevel-order alone
  2. BPreorder and postorder
  3. CPreorder and inorder
  4. DPreorder alone

Answer key

  1. 1. B · Nodes that share the same parent
  2. 2. C · Inserting at the beginning
  3. 3. B · Null (no node)
  4. 4. C · The leftmost node of its right subtree
  5. 5. C · Separate chaining
  6. 6. B · O(1)
  7. 7. A · O(n)
  8. 8. C · Preorder and inorder

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