Algorithm printArray(A,n)
Step 1: Start
Step 2: From i=0 to n-1 Repeat
Step 2.1: print A[i]
Step 3: Stop
Algorithm Main()
Step 1: Start
Step 2: Initialize an Array, A
Step 3: Read the size of array, N
Step 4: Read the elements into the array A
Step 5: Enter the choice 1. Bubble sort 2. Selection Sort 3. Insertion Sort and store the choice in a
variable, ch
Step 6: if ch==1 then,
Step 6.1: print Array Before sorting using printArray()
Step 6.2: From i=0 to n-2 repeat the following
Step 6.2.1: From j=0 to n-2-i repeat the following
Step [Link]: if(A[j]>A[j+1])then,
Step [Link].1: Swap(A[j] and A[j+1])
Step 6.2.2: print the current status of the array
Step 6.3: Print the array after sorting using printArray()
Step 7: if(ch==2) then,
Step 7.1:print the array before sorting using the printArray()
Step 7.2: From i=0 to n-1 Repeat the following
Step 7.2.1: Set min=i
Step 7.2.2: From j=i+1 to n Repeat the following
Step [Link]: if(A[j]<A[min]) then,
Step [Link].1: Set min=j
Step 7.2.3: Swap(A[i] and A[min])
Step 7.2.4: print the current status of the array
Step 7.3: print the final array after sorting
Step 8: if(ch==3) then,
Step 8.1: print the array before sorting using printArray()
Step 8.2: From i=0 to n-1 repeat the following
Step 8.2.1: Set j=i
Step 8.2.2: Repeat until j>0 and Arr[j-1]>Arr[j]
Step [Link]: Swap(Arr[j] and Arr[j-1])
Step [Link]: j - -
Step 8.2.3: print the current status of the array
Step 8.3: print the final array after sorting
Step 9: Else
Step 9.1: Invalid Input Enter either 1 2 or 3
Step 10: Stop