Aim:
To sort list of elements using Insertion sort
Algorithm:
Step1: Start
Step2:Read Upper Limit n
Step3: Read n elements to the list
Step4: Call Function Ssort(list)
Step5: FOR i=1 tle len(a)
Step5.1:currentvalue=a[i]
Step5.2: pos=i
step5.3: WHILE pos>0 and a[pos-1]>currentvalue
Step5.3.1 a[pos]=a[pos-1]
Step5.3.2 pos=pos-1
Step5.3.3 a[pos]=currentvalue
Step6: Print Sorted List
Step7:Return
Step8: Stop
To sort list of elements using Insertion sort
Algorithm:
Step1: Start
Step2:Read Upper Limit n
Step3: Read n elements to the list
Step4: Call Function Ssort(list)
Step5: FOR i=1 tle len(a)
Step5.1:currentvalue=a[i]
Step5.2: pos=i
step5.3: WHILE pos>0 and a[pos-1]>currentvalue
Step5.3.1 a[pos]=a[pos-1]
Step5.3.2 pos=pos-1
Step5.3.3 a[pos]=currentvalue
Step6: Print Sorted List
Step7:Return
Step8: Stop
No comments:
Post a Comment