From ee4d9e0b0ac838d501de1d73146df9c871f20b33 Mon Sep 17 00:00:00 2001 From: Sharannyo Date: Mon, 5 Oct 2020 16:42:44 +0530 Subject: [PATCH 1/2] Added few codes to the DS Folder for reference --- CONTRIBUTING.md | 3 + Data Structure/BubbleSort.cpp | 30 ++++++++ Data Structure/InsertionSort.cpp | 32 +++++++++ Data Structure/Kadane's Algorithm.cpp | 24 +++++++ Data Structure/MoneyChangewithoutSTL.cpp | 24 +++++++ Data Structure/Pair Sum Problem.cpp | 24 +++++++ Data Structure/RadixSort.cpp | 87 ++++++++++++++++++++++++ Data Structure/SelectionSort.cpp | 35 ++++++++++ Data Structure/Wave Print 2D Array.cpp | 24 +++++++ 9 files changed, 283 insertions(+) create mode 100644 Data Structure/BubbleSort.cpp create mode 100644 Data Structure/InsertionSort.cpp create mode 100644 Data Structure/Kadane's Algorithm.cpp create mode 100644 Data Structure/MoneyChangewithoutSTL.cpp create mode 100644 Data Structure/Pair Sum Problem.cpp create mode 100644 Data Structure/RadixSort.cpp create mode 100644 Data Structure/SelectionSort.cpp create mode 100644 Data Structure/Wave Print 2D Array.cpp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b13f6b2..444c661 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,3 +15,6 @@ ### Himanshu Maurya - Github: https://github.com/mauryahimanshu + +### Sharannyo Basu + - Github: https://github.com/sharannyobasu diff --git a/Data Structure/BubbleSort.cpp b/Data Structure/BubbleSort.cpp new file mode 100644 index 0000000..d6d6be7 --- /dev/null +++ b/Data Structure/BubbleSort.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; +void bubble(int a[], int n) +{ + for (int i=1;ia[j+1]) + { + swap(a[j],a[j+1]); + } + } + } +} +int main() +{ + int n, key, arr[1000],i; + cin>>n; + cout<<"Enter elements of the array : "; + for(i =0;i>arr[i]; + } + bubble(arr,n); + for(i=0;i +using namespace std; +void insertion(int a[], int n) +{ + int i,j,e; + for(i=1;i=0 && a[j]>e) + { + a[j+1]=a[j]; + j--; + } + a[j+1]=e; + } +} +int main() +{ + int n, key, arr[1000],i; + cin>>n; + cout<<"Enter elements of the array : "; + for(i =0;i>arr[i]; + } + insertion(arr,n); + for(i=0;i +using namespace std; +int main() +{ + int n; + cin>>n; + int a[1000]; + int cs=0; + int ms=0; + for (int i=0;i>a[i]; + } + for(int i=0;i +#include +using namespace std; + +int main() { + int coins[]={1,2,5,10,20,50,100,200,500,2000}; + int size=sizeof(coins)/sizeof(int); + int n,max; + cout<<"Enter total money : "; + cin>>n; + while(n>0) + { + int i,j; + for(i=0;i +using namespace std; +int main() +{ + int a,i,sum,n,j; + int arr[1000]; + cin>>n; + for(i=0;i>arr[i]; + } + cout<<"Enter sum : "; + cin>>sum; + for(i=0;i +using namespace std; + +void countingsort(int *arr, int n, int div1) +{ + int output[n]; + int count[10]={0}; + + for(int i=0;i=0;i--) + { + output[--count[(arr[i]/div1)%10]]=arr[i]; + //count[(arr[i]/div1)%10]--; + } + for(int i=0;i0;div1*=10) + { + countingsort(arr, n, div1); + } +} + + +int main() +{ + int n; + cin>>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + cout<<"Before sorting : "< +using namespace std; +void selection(int a[], int n) +{ + + for(int i=0;i>n; + cout<<"Enter elelemnts of the array : "; + for(i =0;i>arr[i]; + } + selection(arr,n); + for(i=0;i +using namespace std; +int main() +{ + int a[1000][1000]={0}; + int r,c,i,j; + cin>>r>>c; + for(i=0;i>a[i][j]; + } + } + for(i=0;i Date: Mon, 5 Oct 2020 16:47:35 +0530 Subject: [PATCH 2/2] Updated Contributors file --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 444c661..17867b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,4 +17,4 @@ - Github: https://github.com/mauryahimanshu ### Sharannyo Basu - - Github: https://github.com/sharannyobasu + - Github: https://github.com/sharannyobasu \ No newline at end of file