Selection Sort
Program In C++:- // Selection Sort #include <iostream> using namespace std; void SelectionSort(int a[],int n) { int i,j,temp,large; for(i=n-1;i>0;i--) { large=0; for(j=0;j<=i;j++) if(a[j]>a[large]) large=j; temp=a[i]; a[i]=a[large]; a[large]=temp; } cout<<"\nDisplaying the sorted values:"; for(i=0;i<n;i++) cout<<"\n"<<a[i]; } int main() { int n; cout<<"Enter the size of array:"; cin>>n; int arr[n]; cout<<"Enter the values of array:\n"; for(int i=0;i<n;i++) cin>>arr[i]; SelectionSort(arr,n); } /* output Enter the size of array:3 Enter the values of array: 1 9 2 Displaying the sorted values: 1 2 9 */