MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / insertionSort

Method insertionSort

Programs/InsertionSort.java:12–23  ·  view source on GitHub ↗
(int[] arr)

Source from the content-addressed store, hash-verified

10 }
11 //Insertion Sort Algorithm
12 static void insertionSort(int[] arr) {
13 for (int i = 0; i < arr.length - 1; i++) {
14 for (int j = i+1; j > 0; j--) {
15 if (arr[j] < arr[j-1]) {
16 swap(arr, j, j-1);
17 }
18 else {
19 break;
20 }
21 }
22 }
23 }
24 //Swapping Algorithm
25 static void swap(int[] arr, int first, int second) {
26 int temp = arr[first];

Callers 1

mainMethod · 0.95

Calls 1

swapMethod · 0.95

Tested by

no test coverage detected