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
A hash table stores data as:
- AKey–value pairs located by a hash function
- BA fixed-length string
- CA sorted list only
- DA tree with ordered keys
2.Easy
Which structure is typically used to implement a priority queue?
- AA stack
- BA string
- CA heap
- DA singly linked list without order
3.Easy
In a graph, what is a cycle?
- AA vertex with no edges
- BA path that starts and ends at the same vertex
- CA path that visits every vertex
- DAn edge with a weight of zero
4.Medium
A trie (prefix tree) is especially efficient for:
- ASorting numbers
- BFinding shortest paths
- CPrefix searches such as autocomplete
- DStoring matrices
5.Medium
A road network has 100,000 junctions, each connected to about 4 others. Which representation is most suitable?
- AAdjacency list
- BAdjacency matrix
- CA single sorted array of vertices
- DA binary heap of edges
6.Medium
Which collision resolution method stores colliding keys in a list at the same bucket?
- ADouble hashing
- BLinear probing
- CQuadratic probing
- DSeparate chaining
7.Hard
In the BST with root 50, left subtree 30 (children 20, 40) and right subtree 70 (children 60, 80), the root is deleted using the in-order successor. Which key becomes the new root?
- A80
- B70
- C40
- D60
8.Hard
Which data structure supports an LRU (least recently used) cache with O(1) get and put?
- AA binary search tree only
- BA stack only
- CA hash map combined with a doubly linked list
- DA single sorted array