MCPcopy Create free account
hub / github.com/Manvityagi/PW-Skills-Java-Course-Codes / Main

Class Main

Lecture 39 - Insertion Sort/src/Main.java:1–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1public class Main {
2 static void insertionSort(int[] a){
3 int n = a.length;
4 for(int i = 1; i < n; i++){
5 int j = i;
6 while(j > 0 && a[j] < a[j-1]){
7 int temp = a[j];
8 a[j] = a[j-1];
9 a[j-1] = temp;
10 j--;
11 }
12 }
13 }
14
15 public static void main(String[] args) {
16 int[] a = {8, 3, 6, 5, 4, 2};
17 insertionSort(a);
18 for(int val : a){
19 System.out.print(val + " ");
20 }
21 }
22}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected