Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Shell-Sort C++

C/C++/Java
1  gap = X;
2  do
3  { ok = 1;
4  for (i = 1; i<= N – gap; i++)
5    if (A[i] > A[i+gap])
6    {  temp = A[i];
7       A[i] = A[i+gap];
8       A[i+gap] = temp;
9       ok = 0;
10   }
11 if (gap/2 > 1) gap=gap/2; else gap=1;
12 } while (ok == 0);
Source by mendo.mk #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
8+5 =