Project Nayuki


Master theorem solver (JavaScript)

In the study of complexity theory in computer science, analyzing the asymptotic run time of a recursive algorithm typically requires you to solve a recurrence relation. This JavaScript program automatically solves your given recurrence relation by applying the versatile master theorem (a.k.a. master method). However, it only supports functions that are polynomial or polylogarithmic. (The source code is available for viewing.)

Program

Input

Format: \(T(n) \: = \: a \: T(n \, / \, b) \, + \, Θ(n^k \, (\log n)^i)\).

(usually 0)

Output

Recurrence:
Solution:

Examples

Name & demo \(a\) \(b\) \(k\)
Binary search120
Binary tree traversal220
Merge sort221
Toom-4 multiplication741
Toom-3 multiplication531
Karatsuba multiplication321
Stooge sort31.51
Strassen matrix multiplication722

Click on an example to run the numbers in the calculator.