Advertisement
pedrocasdev

Untitled

Apr 2nd, 2023
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <math.h>
  2. #include <stdio.h>
  3.  
  4. void insertionSort(int arr[], int n)
  5. {
  6.     int i, key, j;
  7.     for (i = 1; i < n; i++) {
  8.         key = arr[i];
  9.         j = i - 1;
  10.  
  11.         while (j >= 0 && arr[j] > key) {
  12.             arr[j + 1] = arr[j];
  13.             j = j - 1;
  14.         }
  15.         arr[j + 1] = key;
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement