Algorithm of sorting
An algorithm to sort an elements using Insertion Sort. Algorithm for Insertion sort:- Step 1 : START Step 2 : Input N Step 3 : For I←0 to N -1 Read A [ I ] ( end of I for loop ) Step 4 : For I←1 to N -1 Do Step 5 : J = I Step 6 : While ( J > = 1 ) and ( A[ J ] < A [ J -1 ] ) Step 7 : TEMP = A [ J ] Step 8 : A [ J ] = A [ J - 1 ] Step 9 : A[ J - 1 ] = TEMP Step 10 : J = J - 1 [ end of While loop ] [ end of step I For loop ] Step 11 : For I←0 to N -1 Step 12: Print A [ I ] Step 13 : Stop Consider the elements A[0 ] 20 A[1] 16 A[2] 4 A [3] 3 Pass 1: A[1],A[0]>16,20,4,3 Pass 2: A[2],A[1]> 16,4,20,3 A[1],A[0]>4,16,20,3 Pass 3: A[3],A[2]> 4,16,3,20 A[2],A[1]>4,3,16,20 A[1],A[0]> 3,4 16,20 Sorted order is 3,4,16,20 Algorithm for bubble sort:- Step 1 : START Step 2 : Input N Step 3 : For I←0 to N -1 Step 4 : Read ( A [ I ] ) ( end of for loop ) Step 5 : F...