java - Fibonacci Series generation using Matrices -
there's 1 question posted fibonacci series, familiar it. there multiple answers , linked questions it. digging through interest, there's solution linked here
this algorithm solves problem o(log(n)) quite impressive. couldn't understand logic , called matrix exponentiation [looked wiki, unable relate it].
so kindly can explain how achieved more details , better explanation [if can explain code, prefer in java, helpful].
thanks :)
what need understand algorithm, not implementation.
the first thing need understand algorithm not give fibonacci numbers, with n power of 2.
the second thing multiplication of sized matrices of course takes constant ( o(1) ) time.
the trick correctly note n'th fibonacci number can formed n-times multiplication of matrix described in link, call m.
you log complexity "reordering" matrix operations from, example m*(m*(m*m)) (m*m)*(m*m). each matrix squaring, go m^2n instead of m^n+1.
Comments
Post a Comment