Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexprut/algorithms

🍒 Classic Algorithms and Data Structures implemented in C++
https://github.com/alexprut/algorithms

algorithms computer-science cplusplus

Last synced: about 1 month ago
JSON representation

🍒 Classic Algorithms and Data Structures implemented in C++

Awesome Lists containing this project

README

        



Algorithms and Data Structures

[![Code Style](https://img.shields.io/badge/code%20style-google-green.svg?style=flat-square)](https://google.github.io/styleguide/cppguide.html)
[![MIT](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/alexprut/design-patterns-java/blob/master/LICENSE)

Classic Algorithms and Data Structures implemented in C++

_Code written for practice. During my Master's degree in Computer Science at the University of Udine._



Algorithms Implemented
======================

|Algorithm|Average Cost|Worst-case Cost|
|---|---|---|
|[Insertion Sort](https://github.com/alexprut/Algorithms/blob/master/insertionSort.cpp)|O(n^2)|O(n^2)|
|[Merge Sort](https://github.com/alexprut/Algorithms/blob/master/mergeSort.cpp)|Θ(nlogn)|Θ(nlogn)|
|[QuickSort](https://github.com/alexprut/Algorithms/blob/master/quickSort.cpp)|O(nlogn)|O(n^2)|
|[Counting Sort](https://github.com/alexprut/Algorithms/blob/master/quickSort.cpp)|O(n+k)|O(n+k)|
|[Binary Search](https://github.com/alexprut/Algorithms/blob/master/binarySearch.cpp)|O(logn)|O(logn)|
|[Bubble Sort](https://github.com/alexprut/Algorithms/blob/master/bubbleSort.cpp)|O(n^2)|O(n^2)|
|[Heapsort](https://github.com/alexprut/Algorithms/blob/master/binaryMaxHeap.cpp#L133)|O(nlogn)|O(nlogn)|
|[Breadth-first Search (BFS)](https://github.com/alexprut/Algorithms/blob/master/breadthFirstSearch.cpp)|O(\|V\|+\|E\|)|O(\|V\|+\|E\|)|
|[Depth-first Search (DFS)](https://github.com/alexprut/Algorithms/blob/master/breadthFirstSearch.cpp)|O(\|V\|+\|E\|)|O(\|V\|+\|E\|)|
|[Prim (MST)](https://github.com/alexprut/Algorithms/blob/master/breadthFirstSearch.cpp)|O(\|E\|log\|V\|)|O(\|E\|log\|V\|)|
|[Kruskal (MST)](https://github.com/alexprut/Algorithms/blob/master/kruskal.cpp)|O(\|E\|log\|V\|)|O(\|E\|log\|V\|)|
|[Bellman-Ford](https://github.com/alexprut/Algorithms/blob/master/bellmanFord.cpp)|O(\|E\|\|V\|)|O(\|E\|\|V\|)|
|[Dijkstra](https://github.com/alexprut/Algorithms/blob/master/dijkstra.cpp)|O(\|E\|+\|V\|log\|V\|)|O(\|E\|+\|V\|log\|V\|)|
|[Maximum subarray (J.Kadane)](https://github.com/alexprut/Algorithms/blob/master/maxSubArray.cpp)|O(n)|O(n)|

Data Structures Implemented
===========================
|Data Structure|Methods|
|--------------|-------|
|[Linked list](https://github.com/alexprut/Algorithms/blob/master/linkedList.cpp)|```insertFront(int value)``` - O(1), ```deleteFront()``` - O(1), ```isEmpty()``` - O(1)|
|[Double Linked list](https://github.com/alexprut/Algorithms/blob/master/doubleLinkedList.cpp)|```insertFront(int value)``` - O(1), ```deleteFront()``` - O(1)|
|[Queue](https://github.com/alexprut/Algorithms/blob/master/queue.cpp)|```enqueue(int value)``` - O(1), ```dequeue()``` - O(1), ```isEmpty()``` - O(1)|
|[Stack](https://github.com/alexprut/Algorithms/blob/master/stack.cpp)|```pop()``` - O(1), ```push()``` - O(1), ```top()``` - O(1), ```isEmpty()``` - O(1)|
|[Binary Search Tree (BST)](https://github.com/alexprut/Algorithms/blob/master/binarySearchTree.cpp)|```insert(int value)``` - Θ(logn), ```search(int value)``` - Θ(logn), ```printInOrder()``` - Θ(n), ```printPreOrder()``` - Θ(n), ```printPostOrder()``` - Θ(n)|
|[Heap (binary max heap)](https://github.com/alexprut/Algorithms/blob/master/binaryMaxHeap.cpp)|```heapify(int index)``` - O(logn), ```insert(int value)``` - O(logn), ```deleteMax()``` - O(logn), ```buildHeap(vector values)``` - O(n), ```heapSort()``` - O(nlogn)|
|[Heap (binary min heap)](https://github.com/alexprut/Algorithms/blob/master/binaryMaxHeap.cpp)|```heapify(int index)``` - O(logn), ```insert(int value)``` - O(logn), ```deleteMin()``` - O(logn), ```buildHeap(vector values)``` - O(n), ```heapSort()``` - O(nlogn)|
|[Disjoint Set](https://github.com/alexprut/Algorithms/blob/master/disjointSet.cpp)|```makeSet()``` - Θ(1), ```findSet()``` - Θ(1), ```union()``` - Θ(1)|
|[Trie](https://github.com/alexprut/Algorithms/blob/master/trie.cpp)|```add()``` - O(\|string\|), ```find()``` - O(\|string\|)|

License
=======
Licensed under [MIT](https://github.com/alexprut/Algorithms/blob/master/LICENSE).