A data structure is required for storing a set of integers such that operations 'deletion of smallest' and 'insertion' can be done in log n time. Which data structure is best?
- A. A heap can be used but not a balanced binary search tree
- B. A balanced binary search tree can be used but not a heap
- C. Both balanced binary search tree and heap can be used
- D. Neither balanced search tree nor heap can be used
Answer: B. A balanced binary search tree can be used but not a heap
Explanation: Heaps support efficient find-min/delete-min but checking 'if element is not already present' (search) is O(n). Balanced BSTs support search, insert, and delete-min all in O(log n).