This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Greedy Algorithm (maximum daily profit from stock sale) - "let me see what my options are, first..." | |
* | |
* Overview: | |
* --------- | |
* By using Greedy Algorithms we can pass over the data once (O(n) time), storing values we find to be optimal, per our criteria, by | |
* comparing them to current values. We have to go over the entire set to do this, but we only have to do it once - yay! | |
* | |
* From Wikipedia: "A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal | |
* choice at each stage with the hope of finding a global optimum." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Merge Sort Algorithm: "divide and conquer", "break you down in order to build you back up" | |
* Overview: | |
* --------- | |
* A recursive sorting algorithm where we 1) divide an unsorted array in half (dismantle big array into tiny sub-arrays) | |
* until we reach atomic values (< 2 - it's never 0), then we 2) sort the adjacent sub-arrays (left, right) and | |
* 3) merge the sorted sub-array values (put things back together) after each iteration | |
* | |
* Time Complexity (worst case): | |
* ----- |
NewerOlder