Divide and Conquer/Master Theorem: Difference between revisions
From charlesreid1
(Created page with "==Statement of Master Theorem== The Master Theorem is used to analyze three distinct cases for divide-and-conquer recurrences: '''Case 1: Subproblems Dominate (Leaf-Heavy)''...") |
No edit summary |
||
| Line 48: | Line 48: | ||
{h(n) : \exist c > 0, n_0, 0 \leq f(n) \leq c g(n)} | {h(n) : \exist c > 0, n_0, 0 \leq f(n) \leq c g(n)} | ||
</math> | </math> | ||
===Macro Convention=== | |||
'''Macro convention''' - a set in a function represents an anonymous function in that set. | |||
Note that this observation is the key mathematical underpinning of functional programming and function-based languages. | |||
==Examples== | ==Examples== | ||
=Flags= | |||
{{AlgorithmsFlag}} | |||
Revision as of 08:32, 16 July 2017
Statement of Master Theorem
The Master Theorem is used to analyze three distinct cases for divide-and-conquer recurrences:
Case 1: Subproblems Dominate (Leaf-Heavy)
If $ f(n) = O(n^{ \log_{b}{(a - \epsilon)} }) $ for some constant $ \epsilon > 0 $ then $ T(n) = \Theta( n^{\log_b{a}} ) $
Case 2: Split/Recombine ~ Subproblems
If $ f(n) = \Theta( n^{\log_b{a}} \log^k{(x)} ) $, then $ T(n) = \Theta( n^{\log_b{a}} \log^{k+1} {n} ) $ (note that usually $ k=0 $)
Case 3: Split/Recombine Dominates (Root Heavy)
If $ f(n) = \Omega( n^{\log_b{(a+\epsilon)}} ) $ for some constant $ \epsilon > 0 $ , and if $ a f(n/b) \leq cf(n) $ for some $ c < 1 $, then $ T(n) = \Theta( f(n) ) $
Revisiting Big O, Big Theta, Big Omega
Big O
When we say
$ f(n) = O(g(n)) $
what we mean is, there are some constants $ c > 0, n_0 > 0 $ such that
$ 0 \leq f(n) \leq c g(n) $
for all sufficiently large $ n \geq n_0 $
We say that f(n) is bounded above by g(n).
Example: $ 2n^2 = O(n^3) $
Big O corresponds roughly to less than or equal to
Note that this equal sign notation is NOT symmetric - n^3 != O(n^2)
We can also think about a set definition - f(n) is in some set of functions that are like g(n)
O(g(n)) can be defined as a set of functions h(n) such that:
$ {h(n) : \exist c > 0, n_0, 0 \leq f(n) \leq c g(n)} $
Macro Convention
Macro convention - a set in a function represents an anonymous function in that set.
Note that this observation is the key mathematical underpinning of functional programming and function-based languages.
Examples
Flags
| Algorithms Part of Computer Science Notes
Series on Algorithms
Algorithms/Sort · Algorithmic Analysis of Sort Functions · Divide and Conquer · Divide and Conquer/Master Theorem Three solid O(n log n) search algorithms: Merge Sort · Heap Sort · Quick Sort Algorithm Analysis/Merge Sort · Algorithm Analysis/Randomized Quick Sort
Algorithms/Search · Binary Search · Binary Search Modifications
Algorithms/Combinatorics · Algorithms/Combinatorics and Heuristics · Algorithms/Optimization · Divide and Conquer
Algorithms/Strings · Algorithm Analysis/Substring Pattern Matching
Algorithm complexity · Theta vs Big O Amortization · Amortization/Aggregate Method · Amortization/Accounting Method Algorithm Analysis/Matrix Multiplication
Estimation Estimation · Estimation/BitsAndBytes
Algorithm Practice and Writeups Project Euler · Five Letter Words · Letter Coverage
|