diff --git a/README.md b/README.md index 4bbb619..65dada9 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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/)

- heap + heap

## Insertion Sort @@ -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/)

-  merge +  merge

## Quick Sort @@ -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/)

-  quick +  quick

## Selection Sort diff --git a/codes/Makefile b/codes/Makefile new file mode 100644 index 0000000..8473314 --- /dev/null +++ b/codes/Makefile @@ -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 diff --git a/codes/insertionsort.cpp b/codes/insertionsort.cpp index 2cc347c..82e86bf 100644 --- a/codes/insertionsort.cpp +++ b/codes/insertionsort.cpp @@ -1,10 +1,10 @@ /* C++ Program - Insertion Sort */ -#include -#include -void main() +#include + +using namespace std; +int main() { - clrscr(); int size, arr[50], i, j, temp; cout<<"Enter Array Size : "; cin>>size; @@ -30,5 +30,4 @@ void main() { cout< -#include -void main() +using namespace std; +int main() { int a[50], n,i,j; cout<<"\nEnter the size of list: "; @@ -19,5 +19,5 @@ void main() } cout<<"\nArranged list is: "; for(i=0; i