분할정복 template
Type divide_and_conquer( S ) {
// (1). Divide the problem into a set of subproblems.
[S1, S2, ... Sn] = divide(S)
// (2). Solve the subproblem recursively,
// obtain the results of subproblems as [R1, R2... Rn].
rets = [divide_and_conquer(Si) for Si in [S1, S2, ... Sn]]
[R1, R2,... Rn] = rets
// (3). combine the results from the subproblems.
// and return the combined result.
return combine([R1, R2,... Rn])
}
'알고리즘 > Template' 카테고리의 다른 글
[Algorithm][Template] 크루스칼 알고리즘 (0) | 2022.01.03 |
---|---|
[Algorithm][Template] 서로소 집합(Disjoint Set), Union-Find (0) | 2022.01.02 |
[Algorithm][Template] 플로이드 워셜 알고리즘 (0) | 2021.12.29 |
[Algorithm][Template] Dijkstra 최단거리 탐색 (0) | 2021.12.18 |
[Algorithm][Template] Backtracking (0) | 2021.10.20 |