Question: For an algorithm that finds X in a pre-sorted array: int Search(int[] data, int x) { for (int i = 0; i < n;
For an algorithm that finds X in a pre-sorted array: int Search(int[] data, int x) { for (int i = 0; i < n; i++) { if(data(i)==x) return i; } return -1; } Create an algorithm that performs better asymptotically than the algorithm abov Determine the worst-case runtime complexity of your algorithm. int binarySearch( int [] data, int x) //todo }
Step by Step Solution
There are 3 Steps involved in it
To create a more efficient algor... View full answer
Get step-by-step solutions from verified subject matter experts
