1. The lower_bound function requires random access iterators. set iterators are of bidirectional type, as a result, the complexity of search will be linear.
2. The correct answer. After adding the data, sort will sort the container using the quick sort algorithm, which usually works 30 to 40% faster than n*logn, and lower_bound(value) performs a binary search.
3. Uses set::lower_bound(), for binary search, however, adding data will take longer than in option 2: (n*logn).
4. unordered_set has bidirectional (forward) iterators. The sort function is not applicable because requires random access iterators.
Login in to like
Login in to comment