Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions HelloWorld/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
#include<stdio.h>
#include<iostream>
#include <iostream>
#include <string>
#include <vector>

int main()
{
printf("Hello World!");
using namespace std;

vector <string> Census;

void Census2017() {
/*
* Add yourself using the following format:
* Census.push_back("Your Name @ https://github.com/username");
*/

Census.push_back("Allen Comp Sci @ https://github.com/AllenCompSci");
Census.push_back("Mr. Hudson @ https://github.com/theshrewedshrew");
Census.push_back("BEST Team 58 @ https://github.com/BESTTeam58");
Census.push_back("TexasSnow @ https://github.com/TexasSnow");
Census.push_back("hotdogshabab @ https://github.com/hotdogshabab");
Census.push_back("alansunglee @ https://github.com/alansunglee");
Census.push_back("Rahultheman12 @ https://github.com/Rahultheman12");
Census.push_back("spicyboi @ https://github.com/spicyboi");
Census.push_back("John Nguyen @ https://github.com/jawnlovesfreestuff");
Census.push_back("CodeTimesTen @ https://github.com/CodeTimesTen");
Census.push_back("YourFriendlyNeighborhoodSpiderman @ https://github.com/YourFriendlyNeighborhoodSpiderman");
Census.push_back("Devin Petersen @ https://github.com/DevinPetersen");
Census.push_back("Cameron Mathis @ https://github.com/Phylux");
Census.push_back("Samuel Woon @ https://github.com/samuel-w");
Census.push_back("JustinV10 @ https://github.com/JustinV10");
Census.push_back("Kyleaustin36 @ https://github.com/kyleaustin36");
Census.push_back("Maaz Kamal @ https://github.com/Maze-Camel");
Census.push_back("bingood4ever @ https://github.com/bingood4ever");
Census.push_back("Gainz101 @ https://github.com/Gainz101");
Census.push_back("zachdogg @ https://github.com/Zachdogg1");
Census.push_back("PJHudson618 @ https://github.com/PJHudson618");
Census.push_back("Abhi1458 @ https://github.com/Abhi1458");
Census.push_back("Maxwell Cody @ https://github.com/MaxwellCody");
}

int main() {
Census2017();

for(int i = 0; i < (int) Census.size(); ++i) {
cout << "Hello World from " << Census[i] << endl;
}

return 0;
}
59 changes: 59 additions & 0 deletions algorithms/SortingAlgorithms/1selSort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <iostream>

using namespace std;

void swap(int a[], int x, int y)
{
int t=a[x];
a[x]=a[y];
a[y]=t;
}

int locOfSmallest(int a[], int s, int e)
{
int i = s;
int j = i;
while(i <= e)
{
if(a[i] < a[j])
{
j = i;
}
i = i+1;
}
return j;
}

void selSort(int a[], int n)
{
int i= 0;
while(i < n-1)
{
int j = locOfSmallest(a,i,n-1);
swap(a, i, j);
i = i+1;
}
}

void show(int a[], int n)
{
int i = 0;
while(i < n)
{
cout << a[i] << ", ";
i = i+1;
}
cout << endl;
}

int main()
{
int arr[] = {22,66,44,27,967,34,2,90,4567,21,75,9,44};


show(arr, sizeof(arr)/sizeof(int));
selSort(arr, sizeof(arr)/sizeof(int));
show(arr, sizeof(arr)/sizeof(int));

return 0;
}
55 changes: 55 additions & 0 deletions algorithms/SortingAlgorithms/2bblSort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <iostream>

using namespace std;

void swap(int a[], int x, int y)
{
int t=a[x];
a[x]=a[y];
a[y]=t;
}

void bubble(int a[], int n)
{
int i = n-1;
while(i > 0)
{
if(a[i] < a[i-1])
{
swap(a,i,i-1);
}
i = i-1;
}
}

void bblSort(int a[], int n)
{
int i= 0;
while(i < n-1)
{
bubble(a,n);
i = i+1;
}
}

void show(int a[], int n)
{
int i = 0;
while(i < n)
{
cout << a[i] << ", ";
i = i+1;
}
cout << endl;
}

int main()
{
int arr[] = {22,66,44,27,967,34,2,90,4567,21,75,9,44};

show(arr, sizeof(arr)/sizeof(int));
bblSort(arr, sizeof(arr)/sizeof(int));
show(arr, sizeof(arr)/sizeof(int));

return 0;
}
48 changes: 48 additions & 0 deletions algorithms/SortingAlgorithms/3insSort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <iostream>

using namespace std;

void insertIth(int a[], int n, int i)
{
int key = a[i];
int j = i-1;
while(j >= 0 && a[j] > key)
{
a[j+1] = a[j];
j = j-1;
}
a[j+1] = key;
}

void insSort(int a[], int n)
{
int i = 1; // second element
while(i < n)
{
insertIth(a,n,i);
i = i+1;
}
}

void show(int a[], int n)
{
int i = 0;
while(i < n)
{
cout << a[i] << ", ";
i = i+1;
}
cout << endl;
}

int main()
{
int arr[] = {22,66,44,27,967,34,2,90,4567,21,75,9,44};
int arrSize = sizeof(arr)/sizeof(int);

show(arr, arrSize);
insSort(arr, arrSize);
show(arr, arrSize);

return 0;
}
87 changes: 87 additions & 0 deletions algorithms/SortingAlgorithms/4mrgSort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include <iostream>

using namespace std;

void combine(int a[], int s, int m, int e)
{
int *buffer = new int [e+1];

int k = s;
while(k <= e)
{
buffer[k] = a[k];
k = k + 1;
}

int i = s;
int j = m+1;
k = s;
while(i <= m && j <= e)
{
if(buffer[i] <= buffer[j])
{
a[k] = buffer[i];
i = i + 1;
}
else
{
a[k] = buffer[j];
j = j + 1;
}
k = k + 1;
}
while(i <= m)
{
a[k] = buffer[i];
i = i + 1;
k = k + 1;
}
while(j <= e)
{
a[k] = buffer[j];
j = j + 1;
k = k + 1;
}

delete[] buffer;
}

void mrgSort(int a[], int s, int e)
{
if (s == e)
{
return;
}
int m = (s+e)/2;
mrgSort(a, s, m);
mrgSort(a, m+1, e);
combine(a,s,m,e);
}

void mrgSort(int a[], int n)
{
mrgSort(a,0,n-1);
}

void show(int a[], int n)
{
int i = 0;
while(i < n)
{
cout << a[i] << ", ";
i = i+1;
}
cout << endl;
}

int main()
{
int arr[] = {22,66,44,27,967,34,2,90,4567,21,75,9,44};
int arrSize = sizeof(arr)/sizeof(int);

show(arr, arrSize);
mrgSort(arr, arrSize);
show(arr, arrSize);

return 0;
}
Loading