Calculation of the complexity of the determinant of a recursive algorithm

I wrote an algorithm for calculating the determinant of the nxn matrix based on the Laplace extension:

equation

I got the repetition ratio below: T(n) = n(nΒ² + T(n-1))

On Wikipedia, I read that this should give the result T(n) = O(n!) , But I don’t know how to prove it (albeit intuitively).

+4
source share
1 answer

The formula is correct, but your repetition ratio is not. You do not need nΒ² , since you do not need to save or generate submatrices.

M ij is the determinant of the submatrix (n-1) x (n-1) . Therefore, you need to calculate the determinants of n for n different matrices. Thus, the correct repetition ratio is T(n) = nβ‹…T(n-1) + 2n-1 . It 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! 

Because of 2β‹…n!/k! ≀ n!/(k-1)! 2β‹…n!/k! ≀ n!/(k-1)! for all k β‰₯ 2 we 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! 

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 your algorithm works in O(n!)

+4
source

Source: https://habr.com/ru/post/1481644/


All Articles