-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorting.cpp
More file actions
73 lines (66 loc) · 1.31 KB
/
sorting.cpp
File metadata and controls
73 lines (66 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<bits/stdc++.h>
using namespace std;
// ? quickSort
// int partition(vector<int> &a, int x, int y){
// int pivot = y;
// int j = x;
// for(int i=x;i<y;++i){
// if(a[i]<a[pivot]) {
// swap(a[i], a[j]);
// j++;
// }
// }
// swap(a[j], a[pivot]);
// return j;
// }
// void quickSort(vector<int> &a, int i, int j){
// int pi = partition(a, i, j);
// if(i<j){
// quickSort(a, i, pi-1);
// quickSort(a, pi+1, j);
// }
// }
//? insetion sort
// void insertionSort(vector<int> &a){
// int n = a.size();
// for(int i=1;i<n;++i){
// int x = i;
// int y = x-1;
// while(y>=0 && a[x]<a[y]){
// swap(a[x], a[y]);
// x--;
// y--;
// }
// }
// }
// ?selection Sort
// void selectionSort(vector<int> &a){
// int n = a.size();
// int j=0;
// while(j<n){
// int minIndex = j;
// for(int i=j+1;i<n;++i){
// if(a[i]<a[minIndex]) minIndex = i;
// }
// swap(a[j], a[minIndex]);
// j++;
// }
// }
// ? bubble sort
// void bubbleSort(vector<int> &a){
// int n = a.size();
// for(int i=n-1;i>=0;--i){
// for(int j=0;j<i;++j){
// if(a[j]>a[j+1]) swap(a[j], a[j+1]);
// }
// }
// }
int main(){
vector<int> a = {9, 1,2,4,2,5,2, 7};
// quickSort(a, 0, (int)(a.size())-1);
// insertionSort(a);
// selectionSort(a);
// bubbleSort(a);
for(auto &A:a) cout<<A<<" ";
return 0;
}