Algorithm
Let a[n] be the given array required to be sorted in descending order
Step 1 : Start
Step 2 : Input elements into array ‘a’
Step 3 : set i to 0
Step 4 : while(i a[j]) then do step10 through step13
{
Step10: position = j
Step11: set checkcounter to 1 [ to check whether any insertion
has taken place]
Step12: go to step14
} [end of if condition]
Step13: add 1 to j
} [ end of j loop ]
Step14: if(checkcounter = 1) then do step15 through step 18
{
Step15: set j to i
Step16 while(j> = position) do step17 and step18
{
Step17: a[j+1] = a[j]
Step18: decrease j by 1
} [end of j loop]
Step19: a[position] = temp
}
Step20: add 1 to i
} [ end of i loop ]
Step21: print the new sorted array ‘a’
Step22: end
Description
Algorithm is given for the Insertion sort method Pls give Ur feed back, it will help me to improve
Presentation Transcript
Your Facebook Friends on WizIQ