From 8fdc89ec29f7cefe5fd260d952fcc6a545cc7c0a Mon Sep 17 00:00:00 2001 From: AarushiKapoor <54901924+AarushiKapoor@users.noreply.github.com> Date: Thu, 1 Oct 2020 02:12:25 +0530 Subject: [PATCH] Update selectionSort.h --- selectionSort.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/selectionSort.h b/selectionSort.h index 9d8560d..79c932e 100644 --- a/selectionSort.h +++ b/selectionSort.h @@ -1,26 +1,28 @@ #include +#include + using namespace std; // SELECTION SORT //------------------------------------------------------- -void selectionSort(vector &v, int n) { - int minPosition, aux; - - for (int i = 0; i < n - 1; i++) { - minPosition = i; // suppose "i" is the minimum - - for (int j = i + 1; j < n; j++) { // find the "min" element in the unsorted part - - if (v[j] < v[minPosition]) { - minPosition = j; +void selectionSort(vector &a, int n) { + int temp,j,small,pos; + for(int i=0;i i) { - swap(v[minPosition], v[i]); + swap(a[i],a[pos]); } } + }