All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · November 2021

A data structure is required for storing a set of integers such that each of the following O(log n) operations can be done in time, where n is the number of elements in the set. Deletion of the smallest element Insertion of an element if it is not already present in the set Which of the following data structures can be used for this purpose?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. A balanced binary search tree can be used but not a heap.

Explanation

A heap deletes the minimum in O(log n) but cannot check 'not already present' faster than O(n). A balanced BST does both in O(log n).

More Data Structures and Algorithms questions