I have a sorted Array and I would like to insert a new element in logarithmic time.
I want to do something like this:
def addElem(Array[Int] data, Int x) {
val pos = java.util.Arrays.binarySearch(data,x);
data.insertAfter(pos, x);
}
Can I do this with an Array?
Should I try a different data structure?