DhaneshchaudharyUnion find by rank and path compression.The above union() and find() are naive and the worst-case time complexity is linear. The trees created to represent subsets can be skewed…Jan 26, 2020Jan 26, 2020
Dhaneshchaudharyfermat’s little theoremFermat’s theorem, also known as Fermat’s little theorem and Fermat’s primality test, in number theory, the statement, first given in 1640…Jan 26, 2020Jan 26, 2020
Dhaneshchaudharyfast exponentiationHow do you efficiently compute a^n for integer n? You could multiply a*a*a*…*a, n-1 multiplications, but there are much more efficient…Jan 26, 2020Jan 26, 2020
DhaneshchaudharyDigit dynamic programmingDigit dp is a very easy technique and also useful to solve many dynamic programming problems. Seeing the name “Digit DP” it’s easy to…Jan 15, 2020Jan 15, 2020
DhaneshchaudharyThe Jacobi MethodThe Jacobi method is a method of solving a matrix equation on a matrix that has no zeros along its main diagonal (Bronshtein and…Jan 13, 2020Jan 13, 2020