Алгоритм сортировки Шелла:

Обозначим

 h[1..t] - массив размеров  шагов

 a[1..n] - сортируемый массив

 k - шаг сортировки

 x - значение вставляемого элемента

 

const t = 3

          h(1) = 7

          h(2) = 3

          h(3) = 1

  for m = 1 to t

    k = h(m)

    for i = 1 + k to n

      x = a(i)

for j = i - k to 1 step  -k

  if  x < a(j) then

                     a( j+k) = a(j)

                      else goto L endif

   next j

   L: a(j+k) = x

 next i

next m

return 

 

        

         Алгоритм быстрой сортировки:

 

Sub Sort (L, R)

 

i = L

j = R

x = a((L + R) div 2)

repeat

  while a(i) < x do

    i = i + 1

  endwhile

  while a(j) > x do

    j = j - 1

  endwhile

  if i <= j then

    y = a(i)

    a(i) = a(j)

    a(j) = y

    i = i + 1

    j = j - 1

  endif

until i > j

if L < j then

                   sort (L, j)

endif

if i < R then

                   sort (i, R)

endif

return

 

 

Sub QuickSort

 

Sort (1, n)

return