My issue
Given a insertionSort function that accepts an array as a parameter, sort the array using the Insertion sort algorithm.
My code
void insertionSort(int arr[], int n) {
// Write your code here
for(int step=1;step<n;step++)
int key=array[step];
int j = step-1;
while(j>=0&& key<array[j])
--j;
}
array[j+1]=key;
}
}
int main(){
int data[6,5,3,1,8,7,2,4];
int n =size of (data)/size of (data[o]);
insertionSort(data,n);
printArray(data,n);
}
Learning course: Design and analysis of Algorithms
Problem Link: https://www.codechef.com/learn/course/abesit-daa/ABESITDA20/problems/SESO42