You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Insertion sort moves elements one place at a time. This can be slow for large arrays where you may need to move the smallest element located in the end to the beginning. Shell sort (by Donald Shell) is based on insertion sort. It swaps elements that are far apart in order to create nearly sorted subsequences. Then these nearly sorted array can be sorted efficiently by insertion sort with a fewer swaps.
git checkout assignment003 to start.
Read about GeneratorType, AnyGenerator, anyGenerator. Complete the given ShellSequence class to generate a Shell sequence going like ⌊n/2⌋, ⌊n/4⌋, ..., 1. The generator should return nil when the value is less than 1.
Write a similar class to create a gap sequence of (3 ^ k - 1) / 2) going as 1, 4, 13, 40, ... We will use the elements less than n in reversed order. For example if n is 200, the sequence should be [121, 40, 13, 4, 1].
Write a shell sort by using one of the generators you created above. Knuth's gap sequence is more performant than Shell's. You may want to read about the performance of other gap sequences.
Due Date: Sunday 13.12.2015
The text was updated successfully, but these errors were encountered:
Insertion sort moves elements one place at a time. This can be slow for large arrays where you may need to move the smallest element located in the end to the beginning. Shell sort (by Donald Shell) is based on insertion sort. It swaps elements that are far apart in order to create nearly sorted subsequences. Then these nearly sorted array can be sorted efficiently by insertion sort with a fewer swaps.
git checkout assignment003
to start.⌊n/2⌋, ⌊n/4⌋, ..., 1
. The generator should return nil when the value is less than 1.(3 ^ k - 1) / 2)
going as1, 4, 13, 40, ...
We will use the elements less than n in reversed order. For example if n is 200, the sequence should be[121, 40, 13, 4, 1]
.Due Date: Sunday 13.12.2015
The text was updated successfully, but these errors were encountered: