File: shellsort.h

package info (click to toggle)
tinyos 2.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 47,476 kB
  • ctags: 36,607
  • sloc: ansic: 63,646; cpp: 14,974; java: 10,358; python: 5,215; makefile: 1,724; sh: 902; asm: 597; xml: 392; perl: 74; awk: 46
file content (20 lines) | stat: -rw-r--r-- 474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*integriert shellsort Algorithmus*/
/*shellsort aufsteigend sortierend aus Kernighan Ritchie (S.61)*/


#ifndef __SHELLSORT_H__
#define __SHELLSORT_H__

void shellsort(uint16_t basis[] , uint16_t size)
{
	int gap, i, j, temp;
	
	for (gap = size/2; gap > 0; gap /= 2)
		for (i = gap; i < size; i++)
			for (j = i-gap; j >= 0 && basis[j] > basis[j+gap]; j-=gap) {
				temp = basis[j];
				basis[j] = basis[j+gap];
				basis[j+gap] = temp;
			}
}
#endif /* __SHELLSORT_H__ */