javascript algotithms
Algorith design techniques to know as a developer
-
Brute force: Simple and exhaustive technique that evaluates every possible outcom to find the best solution. E.g Linear search
-
Greedy: Choose the best option at the current time, without any consideration for the future. E.g Prim's, Kruskal and Dijkstra's algorith
-
Divide and Conquer: Divide the problem into smaller sub-problems. Each sub-problme is then solved and the partial solutiona are recombined to determine the overall solution. E.g Binary search, Quick sort, merge sort and tower of hanoi
-
Dynamic programming: Divide the problem into sub. break it down into smaller but overlapping sub problems. Store the result and reuse it for the same subproblems. This is called memoisation and is a optimisation technique that improves the time complexity of your algorithm. Ex. Fibonacci numbers and climbing staircase
-
Backtracking: Generate all possible solutions. Check if the solution satisfies alll constraints and only then can you proceed with generating subsequent solutions. if the constarints are not satisfied, backtrack and try a different solution. E.g N-Queens problem