Algorithm Templates :
editFibonacci:
edita. Problem
editCompute the nth Fibonacci number
b. Subproblem
edit
c. Recurrence
edit
d. Dependency
edite. Algorithm
editf. Complexity
editTiling Problem :
edita. Problem
editGiven a board that is of dimensions 2 x n , find how many ways it can be tiled using 2 x 1 tiles.
b. Sub Problem
editCount(n) = number of ways to tile a 2 x n board
Compute Count(n)
c. Recurrence
editFailed to parse (unknown function "\begin{cases}"): {\displaystyle Count[n]=\begin{cases} n & \text{if n = 1 or 2} \\ C(n - 1) + C(n - 2) & \text{if $n > 2$}\\ \end{cases}}
d. Algorithm
editnumOfWays(n , hmap){
if (n in hmap)
return hmap[n]
else
hmap[n] = numOfWays(n - 1 , hmap) + numOfWays(n - 2, hmap)
return hmap[n]
}
e. Complexity
editIf the algorithm is written using dp the time complexity is O(n)
Permutation Coefficient :
edita. Problem
editCompute the nth Fibonacci number
b. Subproblem
edit
c. Recurrence
edit