Optimal Binary Search Trees(최적이진탐색트리)
·
Algorithms/Dynamic Programming
Basic ConceptPrerequisite Knowledge: Binary Search Treebinary search tree: A binary tree of items (ordinarily called keys), that come from an ordered set, such thatEach node contain one key.The keys in the right subtree of a given node are greater than or equal to the key in that tree.The keys in the left subtree of a given node are less than or equal to the key in that tree.left subtree: For an..
Chained Matrix Multiplication(연쇄행렬곱셈)
·
Algorithms/Dynamic Programming
Basic ConceptConsider the multiplication of the following four maxtrices. $$A \quad\times\quad B \quad\times\quad C \quad\times\quad D$$$$20\times 2 \qquad 2\times 30 \qquad 30\times 12 \qquad 12\times 8$$ There are five different orders in which we can multiply four matrices, each possibly resulting in a different number of elementary multiplications. The third order is the optimal order for m..
Floyd's Algorithm for Shortest Paths(플로이드 알고리즘)
·
Algorithms/Dynamic Programming
Basic ConceptA common problem encountered by air travelers is the determination of the shortest way to fly from one city to another when a direct flight does not exist. Next we develop an algorithm that solves this and similar problems. First, let’s informally review some graph theory. Prerequisite Knowledge: Graph Theoryvertex, node: 정점edge, arc: 이음선directed graph, digraph: 방향 그래프weight: 가중치sim..
Binomial Coefficient(이항계수)
·
Algorithms/Dynamic Programming
Basic ConceptThe binomial coefficient is given by$$ \begin{pmatrix}n\\k\end{pmatrix}=_nC_k=\frac{n!}{k!\left(n-k\right)!} \text{ for } 0 \le k\le n.$$ For values of n and k that are not small, we cannot compute the binomial coefficient directly from this definition because n! is very large even for moderate values of n. We can eliminate the need to compute n! or k! by using this recursive pro..
Dynamic Programming(동적계획법)
·
Algorithms/Dynamic Programming
Basic ConceptThe divide and conquer algorithm works in problems such as Mergesort, where the smaller instances are unrelated. However, in problems such as nth Fibonacci term, the smaller instances are related. In problems where the smaller instances are related, a divide-and conquer algorithm often ends up repeatedly solving common instances, and the result is a very inefficient algorithm. Recal..