recursion - Complexity computation of a determinant recursive algorithm -
i have written algorithm compute determinant of n x n
matrix, base on laplace expansion:
i got recurrence relation below: t(n) = n(n² + t(n-1))
i read in wikipedia should yield result t(n) = o(n!)
, don't know how prove (although it's intuitive).
the formula correct recurrence relation not. not need n²
, since don't have save or generate sub matrices.
mij
determinant of (n-1) x (n-1)
sub matrix. have compute n
determinants of n
different matrices. correct recurrence relation t(n) = n⋅t(n-1) + 2n-1
. simplifies
t(n) = n ⋅ t(n-1) + 2n-1 = n ⋅ (n-1) ⋅ t(n-2) + n ⋅ (n-1) = n ⋅ ( (n-1) ⋅ ( (n-2) ⋅ (...) + n-3 ) + n-2 ) + n-1 = 2n-1 + n ⋅ (2(n-1)-1) + n ⋅ (n-1) ⋅ (2(n-2)-1) + ... + n! < 2 ⋅ n + 2 ⋅ n ⋅ (n-1) + 2 ⋅ n ⋅ (n-1) ⋅ (n-2) + ... + 2 ⋅ n! + n! = 2 ⋅ (n + n ⋅ (n-1) + ... + n!/2) + 3 ⋅ n! < 2 ⋅ (n!/(n-1)! + n!/(n-2)! + ... + n!/2!) + 3 ⋅ n!
due 2⋅n!/k! ≤ n!/(k-1)!
k ≥ 2
, get
n!/(n-1)! + n!/(n-2)! + n!/(n-3)! + ... + n!/2! ≤ n!/(n-2)! + n!/(n-2)! + n!/(n-3)! + ... + n!/2! ≤ n!/(n-3)! + n!/(n-3)! + ... + n!/2! ≤ n!/(n-4)! + ... + n!/2! ≤ ... ≤ n!/2! + n!/2! ≤ n!
and so
t(n) = n ⋅ t(n-1) + 2n-1 < 2 ⋅ (n!/(n-1)! + n!/(n-2)! + ... + n!/2!) + 3 ⋅ n! ≤ 2 ⋅ n! + 3 ⋅ n! = 5 ⋅ n! = o(n!)
so algorithm runs in o(n!)
Comments
Post a Comment