Having a method and arr being already sorted...
public int search(ArrayList<Integer> arr, int numberToBeSearched) {
//Code here
return //insertion point
}
Let arr be{1, 4, 7} and numberToBeSearched 2. return would be 1 because it would be between 1 and 4 in order to maintain the order.
How would you guys get the insertion point of numberToBeSearched inside arr without using Collections.binarySearch?
The insertion point is the index position where the number would need to be inserted in the array-list so as to maintain the sort order.