Editorial for CPC '19 Contest 1 P4 - Sorting Practice
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Solution Sketch
Subtask 1
For the first subtask, we can use any sort that swaps adjacent elements, such as bubble sort or insertion sort. These sorts take
Time Complexity:
Subtask 2
For the second subtask, we recall that insertion sort works best when the array is nearly sorted. We will consider a solution where for each
Well versed programmers will recognize this as shell sort with Hibbard's gap sequence. It can be shown that this takes
Time Complexity:
Comments