Question: public void insertionSort(int arr[], int n) { int i, j; for(i=2;i < n;i++){ arr[0] = arr[i]; j = 1; while(j
public void insertionSort(int arr[], int n)
{
int i, j;
for(i=2;i< n;i++){
arr[0] = arr[i];
j = 1;
while(j <= i-1){
/* implement your code here /*
/* you must start compare arr[j] with a[0], notice that j = 1 */
}
}
Modify the code so that we are comparing the arr[0] with first item arr[j] and going up (that is j starts from 1 NOT i - 1 !!!!) instead of comparing arr[0] with arr[i-j].
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
