1.Easy
What is the main difference between a static array and a dynamic array?
- AA dynamic array stores its elements in linked nodes so it can grow one at a time
- BA dynamic array can grow by moving to a larger block of memory
- CA static array can only store numbers
- DA static array allows slower index access
2.Easy
What does the peek (or top) operation on a stack do?
- ARemoves the top element and returns it
- BRemoves all elements from the stack
- CReturns the top element without removing it
- DReturns the bottom element of the stack
3.Easy
A graph consists of:
- AVertices (nodes) connected by edges
- BOnly a root and leaves
- CRows and columns
- DKeys and hashes only
4.Medium
An in-order traversal of a binary search tree visits the keys in:
- AAscending sorted order
- BDescending order always
- CLevel order
- DInsertion order
5.Medium
Why can a binary heap be stored in an array without any pointers?
- AArrays automatically keep the keys in sorted order, so no pointers are needed
- BAll keys in a heap are equal
- CHeaps never contain more than 100 elements
- DIt is a complete binary tree, so positions follow simple index formulas
6.Medium
In a hash table using open addressing, what is the maximum possible load factor?
- A2
- B1
- CThere is no maximum
- D0.5
7.Hard
A dynamic array doubles when full. Why do many implementations shrink it only when it is one quarter full, not half full?
- ATo avoid repeated resizing when pushes and pops alternate near the boundary
- BBecause the memory allocator can only release memory in quarters of a block
- CBecause halving at one half would lose elements
- DTo keep the array sorted
8.Hard
Under simple uniform hashing, what is the expected time of a search in a hash table with chaining, n keys and m buckets?
- AO(m)
- BO(1 + α), where α = n / m
- CO(n)
- DO(log n)
Answer key
- 1. B · A dynamic array can grow by moving to a larger block of memory
- 2. C · Returns the top element without removing it
- 3. A · Vertices (nodes) connected by edges
- 4. A · Ascending sorted order
- 5. D · It is a complete binary tree, so positions follow simple index formulas
- 6. B · 1
- 7. A · To avoid repeated resizing when pushes and pops alternate near the boundary
- 8. B · O(1 + α), where α = n / m
Full step-by-step solutions: practise this topic on examproblems.com.