Computer scienceAlgorithms and Data StructuresAlgorithmsPrinciples and techniques

Decrease and conquer

The steps of an insertion sort

Report a typo

Decrease-and-conquer for insertion sort

The above picture illustrates how insertion sort, a decrease-and-conquer-based algorithm, arranges a given array of four numbers in ascending order. In insertion sort, the first element is in the sorted sub-list from the start.

Now, arrange the sequence of steps below to sort an array in descending order.

Put the items in the correct order
Insert the value.
Pick a single element from the unsorted sub-list.
Values in the sorted sub-list are shifted if they are greater than the picked value.
Compare the picked value to a value or values in the sorted sub-list.
___

Create a free account to access the full topic