Function to check if array can be sorted or not
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isSorted ( int arr [ ] , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) return false ; } return true ; }