1.Easy
What is the name of the stack operation that adds an element to the top?
- APush
- BPeek
- CPop
- DEnqueue
2.Easy
A graph consists of:
- AOnly a root and leaves
- BKeys and hashes only
- CVertices (nodes) connected by edges
- DRows and columns
3.Easy
Which operation is O(1) for an array but O(n) for a singly linked list?
- AInserting at the head
- BRemoving the head element
- CReading the first element
- DAccessing the element at index i
4.Medium
How much memory does an adjacency list use for a graph with V vertices and E edges?
- AO(E²)
- BO(V × E)
- CO(V²)
- DO(V + E)
5.Medium
Which data structure is used to check whether the brackets in "{[()]}" are balanced?
- AA binary search tree
- BA stack
- CA queue
- DA hash table
6.Medium
A road network has 100,000 junctions, each connected to about 4 others. Which representation is most suitable?
- AAdjacency matrix
- BAdjacency list
- CA single sorted array of vertices
- DA binary heap of edges
7.Hard
An object is stored as a key in a hash map, and then a field used by its hash function is changed. What is the likely result?
- ALooking up the object may fail because it sits in the bucket for its old hash
- BNothing changes, because a key's hash is computed only once when the program starts
- CThe map automatically moves the key to its new bucket
- DThe map throws an error at the moment the field changes
8.Hard
What is the main advantage of a skip list over a sorted linked list?
- AIt stores keys without order
- BExpected O(log n) search by using several levels of forward pointers
- CIt uses no extra memory
- DGuaranteed O(1) search because every node stores a pointer to every other node
Answer key
- 1. A · Push
- 2. C · Vertices (nodes) connected by edges
- 3. D · Accessing the element at index i
- 4. D · O(V + E)
- 5. B · A stack
- 6. B · Adjacency list
- 7. A · Looking up the object may fail because it sits in the bucket for its old hash
- 8. B · Expected O(log n) search by using several levels of forward pointers
Full step-by-step solutions: practise this topic on examproblems.com.