Here I will add a handful of algorithms from many fields I find useful and interesting.
Preview
GCD stands for Greatest Common Divisor.
Given 2 natural numbers, find their greatest common divisor that divides both of them without leaving any reminder.
Time Complexity: O(log min(a, b))
Preview
Will be used in graph algorithms later on.
Assuming each node is connected to at least one other node.
Can be direcred/undirecred and/or weighted/unweighted.
Using adjacency list.
Default graph is direcred & unweighted (weight = 1).
Preview
To be used in bin packing algorithms.
Preview
At any given time there is only 1 open bin that we check.
It considers the items in an order defined by a list 'items'.
If an item fits inside the currently considered bin, the item is placed inside it.
Otherwise, the current bin is closed, a new bin is opened and the current item is placed inside this new bin.
Time Complexity: O(n) where n = |items|
Approximation Guarantee: 2*OPT(n) where n = |items|
Preview
Finds the position (index) of a target value within a sorted array.
Time Complexity: O(log n) where n = |items|
All algorithms are licensed under the MIT license.
Have fun!