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 "last in, first out"?
- ALinked list
- BStack
- CHash table
- DQueue
2.Easy
The depth of a node in a tree is:
- AThe number of nodes in its subtree
- BThe number of edges from that node to the deepest leaf
- CThe number of edges from the root to that node
- DThe number of children of that node
3.Easy
What is the name of the queue operation that removes the element at the front?
- ADequeue
- BPush
- CInsert
- DEnqueue
4.Medium
A road network has 100,000 junctions, each connected to about 4 others. Which representation is most suitable?
- AA single sorted array of vertices
- BAdjacency list
- CA binary heap of edges
- DAdjacency matrix
5.Medium
Which abstract data type does Dijkstra's algorithm use to choose the next vertex to process?
- AA stack
- BA FIFO queue
- CA set with no ordering
- DA min-priority queue
6.Medium
A node in a binary search tree has a right subtree. Where is its in-order successor?
- AIts right child, always
- BThe rightmost node of its left subtree
- CThe leftmost node of its right subtree
- DIts parent, always
7.Hard
Why might a server choose its hash function at random from a universal family?
- ATo make it very unlikely that an attacker can pick many keys that all collide
- BTo guarantee that no two keys can ever collide, whatever keys an attacker sends
- CTo make the hash table sorted
- DTo remove the need to resize the table
8.Hard
Which property keeps every B-tree perfectly balanced?
- AEvery node has exactly two children
- BAll leaves are at the same depth
- CThe keys are stored only in the root
- DEach node stores one key