1.Easy
What is the name of the stack operation that adds an element to the top?
- AEnqueue
- BPush
- CPop
- DPeek
2.Easy
What does each node in a doubly linked list contain?
- AData, a pointer to the next node and a pointer to the previous node
- BData and two pointers, one to the next node and one to the node after that
- CData and a pointer to the next node only
- DTwo copies of the data and one pointer
3.Easy
How are the elements of an array stored in memory?
- AIn a tree of memory pages
- BIn random locations chosen by a hash
- CIn one contiguous block, one after another
- DScattered, linked by pointers
4.Medium
An in-order traversal of a binary search tree visits the keys in:
- ADescending order always
- BLevel order
- CInsertion order
- DAscending sorted order
5.Medium
Which data structure does a running program use to keep track of active function calls and their local variables?
- AA hash table of functions
- BThe heap memory queue
- CA binary search tree of frames
- DThe call stack
6.Medium
In a binary heap stored in an array starting at index 0, where is the parent of the node at index i?
- AAt index 2i + 1
- BAt index ⌊(i − 1) / 2⌋
- CAt index ⌊i / 2⌋ + 1
- DAt index i − 1
7.Hard
Deleting a node with two children from a binary search tree is usually done by:
- ASwapping it with the root
- BRemoving the whole subtree
- CRebuilding the subtree below it from scratch and reinserting every key it contained
- DReplacing it with its in-order successor (or predecessor) and deleting that node
8.Hard
The time complexity of decrease-key in a binary heap (given the element's position) is:
- AO(n)
- BO(log n)
- CO(1)
- DO(n log n)
Answer key
- 1. B · Push
- 2. A · Data, a pointer to the next node and a pointer to the previous node
- 3. C · In one contiguous block, one after another
- 4. D · Ascending sorted order
- 5. D · The call stack
- 6. B · At index ⌊(i − 1) / 2⌋
- 7. D · Replacing it with its in-order successor (or predecessor) and deleting that node
- 8. B · O(log n)
Full step-by-step solutions: practise this topic on examproblems.com.