I need to use a data structure that can hold a set of integer. However, I need to accomplish add, return frequency of integers, search and return number of integers larger than the integer y (a parameter of the method) with the constraint that every method have to be in O(log n) time.

I plan on using Binary Search Tree so that I can easily do a search in O(log n). However, I do not know how to hold a set of integer (e.g. a list of same integers) in a BST. Can someone give some insight about the data structure to use to accomplish my big-O constraint.

`Map<E, Integer>`

, where`E`

is the type of elements (in your case integers), and the associated`Integer`

value is the number of occurences of that element.– NelfealFeb 14 at 21:19