My issue
correct the code
My code
#include <stdio.h>
// Replace '_' to solve the problem
void Insertion_Sort(int arr[], int n) {
for(int i = 1; i < n; i++) {
int j = i;
int temp = arr[i];
while(j>0 && arr[j-1]>temp ) {
arr[j] = temp;
j--;
}
arr[j-1] =arr[i] ;
}
}
int main() {
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
Insertion_Sort(arr, n);
for(int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}
printf("\n");
return 0;
}
Learning course: Design and Analysis of Algorithms
Problem Link: Insertion Sort in Design and Analysis of Algorithms