MCPcopy Create free account
hub / github.com/Lakhankumawat/LearnCPP / shellSort

Function shellSort

S-SortingAlgorithms/ShellSort.cpp:15–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13using namespace std;
14
15void shellSort(int arr[], int arraySize) {
16
17 int gap = arraySize / 2;
18
19 while (gap >= 1) {//loop stops when there is no more gap between the indices
20
21 for (int i = gap; i < arraySize; i++)
22 {
23 int firstNumber = arr[i];
24
25 int j;
26 for (j = i; (j >= gap) && (arr[j - gap] > firstNumber); j -= gap) {
27 arr[j] = arr[j - gap];
28 }
29 arr[j] = firstNumber;
30 }
31
32 gap /= 2;
33 }
34}
35
36/*
37 * Take the input array from user

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected