Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================
- // Name : shell-sort.cpp
- // Author :
- // Date :
- // Copyright :
- // Description : Implementation of shell sort in C++
- //============================================================================
- #include "sort.h"
- #include <iostream>
- vector<int>
- ShellSort::sort(vector<int>& A, int size)
- {
- for (int gap = size/2; gap > 0; gap /= 2) {
- for (int i = gap; i < size; i += 1) {
- int temp = A[i];
- int j;
- for (j = i; j >= gap && A[j - gap] > temp; j -= gap)
- A[j] = A[j - gap]; num_cmps++;
- A[j] = temp;
- }
- }
- return A;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement