On average, this will also take O(log n) time.
This allows points to be added and deleted in O(log n) time.
We can achieve an O(log n) time solution using skip lists.
This takes O(log n) time and the potential does not change.
The amortized running time of this operation is O(log n).
This can be done in O(log n) without raising the running time of any operation.
Length can also be found in O(log n) time.
The dynamic version may be handled with O(log n) per operation.
We get one of the simplest approximations for log n!
The second problem can also be solved in O(log n) time by binary search.