Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update readme with links and animation of various algos #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
5. [Quick Sort](#quick-sort)
6. [Selection Sort](#selection-sort)

**[Animation of various sorting Algorithms](https://visualgo.net/bn/sorting)**

## Bubble Sort
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
* [Wikipedia](https://en.wikipedia.org/index.php?q=aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvQnViYmxlX3NvcnQ)
Expand All @@ -22,7 +24,7 @@ Heap sort is a comparison based sorting technique based on Binary Heap data stru
* [Wikipedia](https://en.0wikipedia.org/index.php?q=aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvSGVhcHNvcnQ)
* [GeeksForGeeks](http://www.geeksforgeeks.org/heap-sort/)
<p align="center">
<img src="https://en.0wikipedia.org/index.php?q=aHR0cDovL3VwbG9hZC53aWtpbWVkaWEub3JnL3dpa2lwZWRpYS9jb21tb25zLzEvMWIvU29ydGluZ19oZWFwc29ydF9hbmltLmdpZg" alt="heap"/>
<img src="https://upload.wikimedia.org/wikipedia/commons/4/4d/Heapsort-example.gif" alt="heap"/>
</p>

## Insertion Sort
Expand All @@ -38,7 +40,7 @@ Like QuickSort, Merge Sort is a Divide and Conquer algorithm. It divides input a
* [Wikipedia](https://en.wikipedia.org/wiki/Merge_sort)
* [GeeksForGeeks](http://www.geeksforgeeks.org/merge-sort/)
<p align="center">
 <img src="https://en.0wikipedia.org/index.php?q=aHR0cDovL3VwbG9hZC53aWtpbWVkaWEub3JnL3dpa2lwZWRpYS9jb21tb25zL2MvY2MvTWVyZ2Utc29ydC1leGFtcGxlLTMwMHB4LmdpZg" alt="merge"/>
 <img src="https://upload.wikimedia.org/wikipedia/commons/c/cc/Merge-sort-example-300px.gif" alt="merge"/>
</p>

## Quick Sort
Expand All @@ -49,10 +51,10 @@ Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an elemen
-Pick a random element as pivot.
-Pick median as pivot.
The key process in quickSort is partition(). Target of partitions is, given an array and an element x of array as pivot, put x at its correct position in sorted array and put all smaller elements (smaller than x) before x, and put all greater elements (greater than x) after x. All this should be done in linear time.
* [Wikipedia](https://en.wikipedia.org/index.php?q=aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvUXVpY2tzb3J0)
* [Wikipedia](https://en.wikipedia.org/wiki/Quicksort)
* [GeeksForGeeks](http://www.geeksforgeeks.org/quick-sort/)
<p align="center">
 <img src="https://en.0wikipedia.org/index.php?q=aHR0cDovL3VwbG9hZC53aWtpbWVkaWEub3JnL3dpa2lwZWRpYS9jb21tb25zLzYvNmEvU29ydGluZ19xdWlja3NvcnRfYW5pbS5naWY" alt="quick"/>
 <img src="https://upload.wikimedia.org/wikipedia/commons/6/6a/Sorting_quicksort_anim.gif" alt="quick"/>
</p>

## Selection Sort
Expand Down
31 changes: 31 additions & 0 deletions codes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
all: binary_search bubblesort heapsort insertionsort linear_search mergesort qsort selectionsort

CC=g++
CFLAGS=-Wall -c

binary_search.o: binary_search.cpp
$(CC) $(CFLAGS) binary_search.cpp

bubblesort.o: bubblesort.cpp
$(CC) $(CFLAGS) bubblesort.cpp

heapsort.o: heapsort.cpp
$(CC) $(CFLAGS) heapsort.cpp

insertionsort.o: insertionsort.cpp
$(CC) $(CFLAGS) insertionsort.cpp

linear_search.o: linear_search.cpp
$(CC) $(CFLAGS) linear_search.cpp

mergesort.o: mergesort.cpp
$(CC) $(CFLAGS) mergesort.cpp

qsort.o: qsort.cpp
$(CC) $(CFLAGS) qsort.cpp

selectionsort.o: selectionsort.cpp
$(CC) $(CFLAGS) selectionsort.cpp

clean:
rm -f *.o binary_search bubblesort heapsort insertionsort linear_search mergesort qsort selectionsort
11 changes: 5 additions & 6 deletions codes/insertionsort.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* C++ Program - Insertion Sort */

#include<iostream.h>
#include<conio.h>
void main()
#include <iostream>

using namespace std;
int main()
{
clrscr();
int size, arr[50], i, j, temp;
cout<<"Enter Array Size : ";
cin>>size;
Expand All @@ -30,5 +30,4 @@ void main()
{
cout<<arr[i]<<" ";
}
getch();
}
}
6 changes: 3 additions & 3 deletions codes/selectionsort.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include<iostream>
#include<iomanip.h>

void main()
using namespace std;
int main()
{
int a[50], n,i,j;
cout<<"\nEnter the size of list: ";
Expand All @@ -19,5 +19,5 @@ void main()
}
cout<<"\nArranged list is: ";
for(i=0; i<n; i++)
cout<< setw(5) << a[i];
cout<< a[i];
}