My issue
hii hloo
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];
// Moves elements until the element is at its right position
while(j > 0 && arr[j - 1] > temp) {
arr[j] = arr[j - 1];
j--;
}
arr[j] = temp;
}
}
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