Skip to content

Files

Latest commit

9987a3c · Mar 6, 2018

History

History

233-meet-comb-sort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018

Meet Comb sort

Challenge Description:

Comb sort is a simplified sorting algorithm, an improvement of a bubble sort algorithm. It competes in speed with a well-known quick sort algorithm.
The main idea of this sorting algorithm is that a gap between elements can be more than 1.
Such algorithm is used in this challenge.

Input sample:

The first argument is a path to a file. Every row includes a test case with numbers that you need to sort using comb sort algorithm.

3 1 2
5 4 3 2 1

Output sample:

Count and print number of iterations it will take to sort the test case using comb sort. Iteration is a pass through the list of numbers using the same range between the compared elements. When a pass starts from the beginning – it’s a new iteration. If a range is, for example, 3, then take elements 0 and 3, then 1 and 4 etc.

2
3

Constraints:

  1. Decrease factor for the algorithm is 1.25; round the result to a smaller number.
  2. If a range is, for example, 3, then take elements 0 and 3, then 1 and 4 etc.
  3. One iteration for this algorithm is a pass through the list of numbers to the end using the same range between the compared elements.
  4. The number of test cases is 40.