Algorithms

Greedy

Greedy algorithms basically check the entire input and doesn't care to try reducing it.

Ex.: Linear Search

Divide and Conquer

Split your input into chunks, analyse it then re-split it and on and on... to hopefully solve things faster.

Ex.: Recursion or Binary Search

Recursion

Resolve something by breaking down the problem and re-looking at it until you reach a base case.

function factorial(n: number): number {
    // Base case
    if (n === 1) return 1;
    
    // Recurse
    return n * factorial(n - 1);
}

3 sections of recursion

Recursive functions can be broken down in three sections:

Dynamic Programming

Last updated