Saturday, October 21, 2017

Selection Sort

Aim:
       To sort list of elements using selection 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(list)
   Step5.1: least=1
   Step5.2: pos=i
   step5.3: FOR k=i+1 to len(list)
       Step5.3.1 IF list[k]<list[least] THEN least=k
   Step5.4: SWAP(list[least],list[i])
Step6: Print Sorted List
Step7:Return
Step8: Stop

https://drive.google.com/file/d/0ByMcz7t6A0giZk5KbUh4ay1pb2s/view?usp=sharing


Insertion Sort

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

https://drive.google.com/file/d/0ByMcz7t6A0giUW1CTGEtRmNzb0U/view?usp=sharing



Find the maximum of a list of numbers

Aim
  To write a program to find maximum number of a list of numbers.
Algorithm:
Step1:  Start
Step2:  Read Upper Limit of the List
Step3: Read element to the list using loop until upper Limit
Step4: Set first element as maxno=list[0]
Step5: Set i=0
Step6: If list [i] >maxno then set maxno=list1[i]
Step7: Increment i by 1
Step8: Repeat Step 6-7 till i<size (Where size is the size of list).
Step9: Print Maximum Number maxno
Step10: Stop
https://drive.google.com/file/d/0ByMcz7t6A0gicjk2alg0VWNPSWM/view?usp=sharing