From 02c986d68a2f1873bb685f7d1234018eea14e0df Mon Sep 17 00:00:00 2001
From: Kapil Verma <43838373+kapilk535@users.noreply.github.com>
Date: Fri, 30 Oct 2020 18:01:33 +0530
Subject: [PATCH] Create Selection_Sort.cpp

Add selection sort using stl in c++
---
 sort_search_problems/Selection_Sort.cpp | 51 +++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 sort_search_problems/Selection_Sort.cpp

diff --git a/sort_search_problems/Selection_Sort.cpp b/sort_search_problems/Selection_Sort.cpp
new file mode 100644
index 0000000..5960eca
--- /dev/null
+++ b/sort_search_problems/Selection_Sort.cpp
@@ -0,0 +1,51 @@
+#include <iostream>
+#include <bits/stdc++.h>
+
+using namespace std;
+
+void
+swapi (int *a, int *b)
+{
+  int t = *a;
+  *a = *b;
+  *b = t;
+  // cout << *a << " " << *b << endl;
+}
+
+
+vector < int >
+selectionSort (vector < int >arr, int n)
+{
+  int i, j, min_idx;
+
+  // One by one move boundary of unsorted subarray  
+  for (i = 0; i < n - 1; i++)
+    {
+      // Find the minimum element in unsorted array  
+      min_idx = i;
+      for (j = i + 1; j < n; j++)
+	if (arr[j] < arr[min_idx])
+	  min_idx = j;
+
+      // Swap the found minimum element with the first element  
+      swapi (&arr[min_idx], &arr[i]);
+    }
+  return arr;
+}
+
+
+
+int
+main ()
+{
+//   cout << "Hello World\n";
+  std::vector < int >vec;
+  vec = {202, 4, -5, 66, -2, 0, 96, 5, 78, 12, 48, 88};
+
+  vec = selectionSort (vec, vec.size());
+    for (int x:vec)
+    {
+      cout << x << " ";
+    }
+  return 0;
+}