hamza1886 / master-theorem

Learn to solve recurrence relations and find asymptotic complexity of decreasing and dividing functions using master theorem.

Home Page:http://drunkdeveloper.com/app/master-theorem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solve Recurrence Relation using Master Theorem

Learn to solve recurrence relations and find asymptotic complexity of decreasing and dividing functions using master theorem. See online demo.

Master Theorem

Master theorem provides an asymptotic analysis (using Big O notation) for recurrence relations that occur in the analysis of many divide and conquer algorithms. The approach was first presented by Jon Bentley, Dorothea Haken, and James B. Saxe in 1980, where it was described as a "unifying method" for solving such recurrences. The name "master theorem" was popularized by the widely used algorithms textbook Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein.

Divide and Conquer

Let a ≥ 1 and b > 1 be constants, let f(n) be a function, and let T(n) be a function over the positive numbers defined by the recurrence
T(n) = aT(n/b) + f(n) where
  • a ≥ 1,
  • b > 1, and
  • f(n) = Θ(nk logp n), where k ≥ 0 and p ≥ 0
Case 1: If logb a > k then Θ(nlogb a)
Case 2: If logb a = k then
  1. if p > -1 then Θ(nk logp+1 n)
  2. if p = -1 then Θ(nk log log n)
  3. if p < -1 then Θ(nk)
Case 3: If logb a < k then
  1. if p > 0 then Θ(nk logp n)
  2. if p ≤ 0 then Θ(nk)

Decrease and Conquer

Let a > 0 and b > 0 be constants, let f(n) be a function, and let T(n) be a function over the positive numbers defined by the recurrence
T(n) = aT(n - b) + f(n) where
  • a > 0,
  • b > 0, and
  • f(n) = Θ(nk logp n), where k ≥ 0 and p ≥ 0
Case 1: If a < 1 then Θ(f(n)) = Θ(nk logp n)
Case 2: If a = 1 then Θ(n * f(n)) = Θ(nk+1 logp n)
Case 3: If a > 1 then Θ(an/b * f(n)) = Θ(an/b nk logp n)

Solve Recurrence Relation

solve recurrence relation using master theorem

License

The code is open-sourced, licensed under the MIT license.

About

Learn to solve recurrence relations and find asymptotic complexity of decreasing and dividing functions using master theorem.

http://drunkdeveloper.com/app/master-theorem

License:MIT License


Languages

Language:PHP 100.0%