Problem solving paradigms

Four Common Problem Solving Paradigms

Given a simple task involving an array A with up to 200K positive integers whose value can be up to 1M.

Strategies

Problem size Worst accepted algorithm
≤ [10..11] O(n!), O(n6)
≤ [17..19] O(2n * n2)
≤ [18..22] O(2n * n)
≤ [24..26] O(2n)
≤ 100 O(n4)
≤ 450 O(n3)
≤ 1.5K O(n2.5)
≤ 2.5K O(n2log(n))
≤ 10K O(n2)
≤ 200K O(n1.5)
≤ 4.5M O(nlog(n))
≤ 10M O(nlog(log(n)))
≤ 100M O(n), O(log(n)), O(1)

Improving Complete Search: Looping and Pruning

Iterative Complete Search: Permutations

Recursive Complete Search: Backtracking

Challenges

Complete Search Tips:

Divide and Conquer (D&C):

D&C Binary Search: Uncommon Data Structures

D&C Binary Search: Binary Search the Answer

Challenges

Greedy

Challenges

Dynamic Programming (DP)

Dynamic Programming (DP): Example

Non DP Approaches

Top-down DP:

Bottom-up DP:

LeetCode example