.

Comb Sort Algorithm Assignment Help

Comb sort is a relatively simple sorting algorithm initially created by Wlodzimierz Dobosiewicz in 1980. Later on it had been rediscovered through Stephen Lacey and Richard Box in 1991. Comb sort improves on bubble sort.

Comb Sort Algorithm :

Algorithm C (comb sort)

  • Step1: Set gap = input.size, swap=1, shrink= 1.3
  • Step2: If gap == 1 and swap == 0, then terminate
  • Step3: If gap > 1, set gap = floor( gap/shrink )
  • Step4: Set j = 0, swap = 0
  • Step5: If j+gap >= input.size , go to Step2
  • Step6: If input[ j ] > input[ j+gap ], Set temp = input[ j ], input[ j ] = input[ j+gap ], input[ j + gap ] = input[ j ], swap = swap + 1
  • Step7: j = j + 1, go to Step5

The advantage and disadvantage:

  • The advantage:
    • Comb sort is often a very innovative sorting algorithm with average as well as worst case each under O( nlogn ), it's reliable, and unlike other high level sorting algorithm, it is relatively simplistic.
  • The disadvantage:
    • Even though comb sort is under O( nlogn ), it's overall performance isn't just like expected. It's even slower than its brother, shell sort, that using the O( n^3/2 ) in the most case.
.