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
What is the name of the queue operation that removes the element at the front?
ADequeue
BInsert
CPush
DEnqueue
2.Easy
Which data structure works on the principle "first in, first out"?
AStack
BQueue
CBinary tree
DHeap
3.Easy
A graph consists of:
AOnly a root and leaves
BVertices (nodes) connected by edges
CKeys and hashes only
DRows and columns
4.Medium
How is a new element inserted into a binary heap?
AInsert it at its sorted position by shifting all of the larger elements one place right
BPlace it at the end of the array and sift it up while it violates the heap property
CRebuild the whole heap from scratch
DPlace it at the root and sift it down
5.Medium
What is the time complexity of searching for a key in a balanced binary search tree?
AO(n log n)
BO(1)
CO(log n)
DO(n)
6.Medium
What is the cost of inserting an element in the middle of an array of n elements?
AO(log n), because of binary search
BO(n), because later elements must shift
CO(1), because the index is known
DO(n²), because each element moves n times
7.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
8.Hard
Which property keeps every B-tree perfectly balanced?
AAll leaves are at the same depth
BEvery node has exactly two children
CEach node stores one key
DThe keys are stored only in the root
Answer key
1. A · Dequeue
2. B · Queue
3. B · Vertices (nodes) connected by edges
4. B · Place it at the end of the array and sift it up while it violates the heap property
5. C · O(log n)
6. B · O(n), because later elements must shift
7. C · A hash map combined with a doubly linked list
8. A · All leaves are at the same depth
Full step-by-step solutions: practise this topic on examproblems.com.