This repository stores some algorithm exercises, which is something like a cheatsheet that I can refer back later. All codes are in code
directory.
0 pick_based_on_prob.py
: 3 ways to implement picking one element from an array (or list) with probability assigned.- Giant array pool method
- Accept/Rejection method
- Bar method (RECOMMENDED)
1 genetic_algorithm.py
: An easy example to implement the genetic algorithm (GA).2 sorting.py
: Commen sorting algorithms- Insertion sort
- Merge sort
- Quick sort
- Counting sort
3 heapsort.py
: Heap sort algorithm.4 divide_and_conquer.py
: Some algorithms that implement the Divide and Conquer method.- Binary search
- Calculate the n power of x
- Fibonacci using matrix tricks
5 linear_regression.py
: Implementation of multivariable linear regression.