SlideShare a Scribd company logo
1 of 19
By POSTECH Computer Algorithm Team
분할정복
남진환
Dvide & Conquer
Contents
POSTECH Computer Algorithm Team
Master Theorem 05
분할정복 03
FENCE 08
문제 18
POSTECH Computer Algorithm Team
분할정복의 가장 기본적인 아이디어는, 어떤 문제를 풀기 위해 그 문제를 여러 개로 나누어서 푼 후, 그 해답을 합
쳐서 최종적인 해답을 도출하는 것이다.
포스텍에서 가장 키가 큰 사람을 찾기 위해 각 학번마다 키가 가장 큰 사람을 찾아내서 비교하고, 각 학번에서 키
가 가장 큰 사람을 찾기 위해 동일 학번내의 각 분반에서 키가 가장 큰 사람을 찾아내서 비교한다면 분할정복의 아
이디어를 사용한 것이다.
분할정복
POSTECH Computer Algorithm Team
분할정복은 다음과 같은 때에 주로 사용된다.
1. 주어진 문제가 조금 더 작은 범위인 여러 개의 같은 문제로 나뉠 수 있을 때
2. 각 소문제가 대문제와 근본적으로 동일한 재귀적 방법으로 해결될 때
3. 각 소문제들의 해답을 합침으로써 대문제를 풀 수 있을 때
분할정복
POSTECH Computer Algorithm Team
마스터 정리는, 문제를 재귀적으로 푸는 알고리즘의 시간 복잡도를 간단하게 구하는 방법이다.
모든 재귀적 알고리즘의 시간 복잡도를 구할 수 있는 것은 아니지만, 상당히 유용하게 쓰인다.
길이 N의 문제를 푸는데에 T(N)이 걸린다고 하자.
이때, T(N)은 T(N) = aT(
𝑁
𝑏
) + 𝑓(𝑁) 이라는 점화식을 만족한다. (a > 0, b > 1)
그렇다면,
T(N) ∈ O(𝑁log 𝑏 𝑎
) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 − 𝜀
) for some constant 𝜀 > 0
O(𝑁log 𝑏 𝑎
log 𝑁) 𝑖𝑓 𝑓 𝑁 ∈ O(𝑁log 𝑏 𝑎
)
O(f(N)) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 + 𝜀
) 이고 충분히 큰 N과 1보다 큰 c에 대해 af(
𝑁
𝑏
) ≤ 𝑐𝑓 𝑁
Master Theorem
POSTECH Computer Algorithm Team
Master Theorem의 직관적인 설명
g(n) = 𝑛log 𝑏 𝑎
라 할 때,
1. g(n)이 더 무거우면 g(n)이 시간 복잡도를 결정한다
2. g(n)과 f(n)의 무게가 같다면 g(n)에 log 𝑛 을 곱한 것이 시간 복잡도이다
3. f(n)이 더 무거우면 f(n)이 시간 복잡도를 결정한다
Master Theorem https://blog.naver.com/yyj9301/221240585554
POSTECH Computer Algorithm Team
Master Theorem
POSTECH Computer Algorithm Team
히스토그램은 직사각형 여러 개가 아래쪽으로 정렬되어 있는 도형이다. 각 직사각형은 같은 너비를 가지고 있지만,
높이는 서로 다를 수도 있다. 예를 들어, 왼쪽 그림은 높이가 2, 1, 4, 5, 1, 3, 3이고 너비가 1인 직사각형으로 이
루어진 히스토그램이다. 히스토그램에서 가장 넓이가 큰 직사각형을 구하는 프로그램을 작성하시오.
FENCE https://algospot.com/judge/problem/read/FENCE
POSTECH Computer Algorithm Team
FENCE
POSTECH Computer Algorithm Team
- 무식하게 푼다면 O(𝑁2
)이 걸린다!
- 분할정복: 나눈다 -> 푼다 -> 합친다
이 문제에서,
나누는 것은 히스토그램을 왼쪽 오른쪽으로 나누는 것이고
푸는 것은 왼쪽과 오른쪽의 히스토그램에서 가장 큰 직사각형의 넓이를 구하는 것이다
그렇다면 합치는 것은?
왼쪽과 오른쪽의 최댓값을 비교하기만 하면 안된다.
왼쪽 부분과 오른쪽 부분의 히스토그램을 모두 사용할 때의 최댓값도 구해야한다!
FENCE
POSTECH Computer Algorithm Team
FENCE
먼저, 왼쪽과 오른쪽 부분이 모두 포함되어야 하기 때문에 중앙의 두 막대를 포함하고 시작한다.
POSTECH Computer Algorithm Team
FENCE
그 다음, 선택된 막대의 왼쪽과 오른쪽 막대의 높이를 비교한다.
그 중 높이가 더 큰 막대를 선택한다.
POSTECH Computer Algorithm Team
FENCE
POSTECH Computer Algorithm Team
FENCE
다시, 선택된 막대의 왼쪽과 오른쪽 막대 중 높이가 더 큰 것을 선택한다.
POSTECH Computer Algorithm Team
FENCE
이와 같은 행위를 반복하면, 왼쪽과 오른쪽 부분을 동시에 사용하며 넓이가 가장 큰 직사각형을 찾을 수 있다.
여기서, 합치는 과정의 시간 복잡도는 O(N)이다.
POSTECH Computer Algorithm Team
이와 같은 방법으로, 우리는 문제를 해결할 수 있다.
- 그렇다면 이 알고리즘의 시간 복잡도는?
길이 N짜리 문제를 풀기 위해서는 길이
𝑁
2
짜리 문제를 2개 풀어야 하고, 합치는 과정에서 N만큼의 시간이 필요하다.
길이
𝑁
2
짜리 문제를 풀기 위해서는 길이
𝑁
4
짜리 문제를 2개 풀어야 하고, 합치는 과정에서
𝑁
2
만큼의 시간이 필요하다.
길이
𝑁
4
짜리 문제를 풀기 위해서는 . . .
Master Theorem을 적용해보자!
FENCE
POSTECH Computer Algorithm Team
문제에서, T(N) = 2T(
𝑁
2
) + 𝑁
Master Theorem에서 a = 2, b = 2, f(N) = N인 경우이다. 조건에 대입해보자.
T(N) ∈ O(𝑁log 𝑏 𝑎
) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 − 𝜀
) for some constant 𝜀 > 0
O(𝑁log 𝑏 𝑎
log 𝑁) 𝑖𝑓 𝑓 𝑁 ∈ O(𝑁log 𝑏 𝑎
)
O(f(N)) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 + 𝜀
) 이고 충분히 큰 N과 1보다 큰 c에 대해 af(
𝑁
𝑏
) ≤ 𝑐𝑓 𝑁
f(N) ∈ O(N)이고 log 𝑏 𝑎 = 1 이므로 가운데에 해당된다.
=> T(N) ∈ (NlogN)
FENCE
POSTECH Computer Algorithm Team
https://algospot.com/judge/problem/read/QUADTREE - QUADTREE
https://algospot.com/judge/problem/read/FENCE – FENCE
https://www.acmicpc.net/problem/2751 – Merge Sort
https://algospot.com/judge/problem/read/FANMEETING - FANMEETING
https://www.acmicpc.net/problem/1992 - 쿼드트리의 이해를 돕기 위한 문제
문제 풀기
POSCAT
Thank you :-)

More Related Content

What's hot

쏙 알고스터디 01
쏙 알고스터디 01쏙 알고스터디 01
쏙 알고스터디 01Jisu Lee
 
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05Seok-joon Yun
 
Doing mathwithpython.ch02
Doing mathwithpython.ch02Doing mathwithpython.ch02
Doing mathwithpython.ch02Seok-joon Yun
 
Doing math with python.ch07
Doing math with python.ch07Doing math with python.ch07
Doing math with python.ch07Seok-joon Yun
 
[D2CAMPUS] Algorithm tips - ALGOS
[D2CAMPUS] Algorithm tips - ALGOS[D2CAMPUS] Algorithm tips - ALGOS
[D2CAMPUS] Algorithm tips - ALGOSNAVER D2
 
The Art of Computer Programming 2.3.2 Tree
The Art of Computer Programming 2.3.2 TreeThe Art of Computer Programming 2.3.2 Tree
The Art of Computer Programming 2.3.2 Treehyun soomyung
 
Graph mst
Graph mstGraph mst
Graph mstGNGLB
 
2019 ppc answers
2019 ppc answers2019 ppc answers
2019 ppc answers승혁 조
 
Numerical Method
Numerical MethodNumerical Method
Numerical MethodULUG
 
DP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfDP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfHo Jeong Im
 
2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차Moonki Choi
 
2.linear regression and logistic regression
2.linear regression and logistic regression2.linear regression and logistic regression
2.linear regression and logistic regressionHaesun Park
 

What's hot (12)

쏙 알고스터디 01
쏙 알고스터디 01쏙 알고스터디 01
쏙 알고스터디 01
 
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05
 
Doing mathwithpython.ch02
Doing mathwithpython.ch02Doing mathwithpython.ch02
Doing mathwithpython.ch02
 
Doing math with python.ch07
Doing math with python.ch07Doing math with python.ch07
Doing math with python.ch07
 
[D2CAMPUS] Algorithm tips - ALGOS
[D2CAMPUS] Algorithm tips - ALGOS[D2CAMPUS] Algorithm tips - ALGOS
[D2CAMPUS] Algorithm tips - ALGOS
 
The Art of Computer Programming 2.3.2 Tree
The Art of Computer Programming 2.3.2 TreeThe Art of Computer Programming 2.3.2 Tree
The Art of Computer Programming 2.3.2 Tree
 
Graph mst
Graph mstGraph mst
Graph mst
 
2019 ppc answers
2019 ppc answers2019 ppc answers
2019 ppc answers
 
Numerical Method
Numerical MethodNumerical Method
Numerical Method
 
DP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfDP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdf
 
2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차
 
2.linear regression and logistic regression
2.linear regression and logistic regression2.linear regression and logistic regression
2.linear regression and logistic regression
 

Similar to 분할정복

Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexityskku_npc
 
Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리SANG WON PARK
 
자료구조1보고서
자료구조1보고서자료구조1보고서
자료구조1보고서KimChangHoen
 
01. c and time complexity
01. c and time complexity01. c and time complexity
01. c and time complexity승혁 조
 
Acmicpcseminar5
Acmicpcseminar5Acmicpcseminar5
Acmicpcseminar5yonsei
 
알고리즘 스터디 NP-완비
알고리즘 스터디 NP-완비알고리즘 스터디 NP-완비
알고리즘 스터디 NP-완비SeungMin Yang
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)Jeonghun Yoon
 
[Algorithm] Big O Notation
[Algorithm] Big O Notation[Algorithm] Big O Notation
[Algorithm] Big O NotationBill Kim
 
Escamp Seminar @KAIST
Escamp Seminar @KAISTEscamp Seminar @KAIST
Escamp Seminar @KAISTDaegeun Lee
 
[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이
[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이
[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이NAVER D2
 
[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘
[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘
[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘GDGCampusKorea
 
Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Jeonghun Yoon
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]강민국 강민국
 

Similar to 분할정복 (20)

Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexity
 
Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리
 
자료구조1보고서
자료구조1보고서자료구조1보고서
자료구조1보고서
 
Number theory
Number theoryNumber theory
Number theory
 
01. c and time complexity
01. c and time complexity01. c and time complexity
01. c and time complexity
 
Acmicpcseminar5
Acmicpcseminar5Acmicpcseminar5
Acmicpcseminar5
 
알고리즘 스터디 NP-완비
알고리즘 스터디 NP-완비알고리즘 스터디 NP-완비
알고리즘 스터디 NP-완비
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)
 
자료구조01
자료구조01자료구조01
자료구조01
 
자료구조01
자료구조01자료구조01
자료구조01
 
자료구조01
자료구조01자료구조01
자료구조01
 
0207 1 gradient
0207 1 gradient0207 1 gradient
0207 1 gradient
 
[Algorithm] Big O Notation
[Algorithm] Big O Notation[Algorithm] Big O Notation
[Algorithm] Big O Notation
 
Escamp Seminar @KAIST
Escamp Seminar @KAISTEscamp Seminar @KAIST
Escamp Seminar @KAIST
 
[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이
[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이
[D2 CAMPUS] 숭실대 SCCC 프로그래밍 경시대회 문제 풀이
 
approximation algorithm
approximation algorithmapproximation algorithm
approximation algorithm
 
[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘
[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘
[Devfest Campus Korea 2021]효율적인 문제해결 With 알고리즘
 
Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)
 
2016 UCPC 풀이
2016 UCPC 풀이2016 UCPC 풀이
2016 UCPC 풀이
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]
 

More from 승혁 조

RSS Live Slider
RSS Live SliderRSS Live Slider
RSS Live Slider승혁 조
 
Parallel binary search
Parallel binary searchParallel binary search
Parallel binary search승혁 조
 
Geometry Algorithms
Geometry AlgorithmsGeometry Algorithms
Geometry Algorithms승혁 조
 
Heavy light decomposition
Heavy light decompositionHeavy light decomposition
Heavy light decomposition승혁 조
 
Advanced segment tree
Advanced segment treeAdvanced segment tree
Advanced segment tree승혁 조
 
L-R network flow
L-R network flowL-R network flow
L-R network flow승혁 조
 
Sqrt(n) algorithm
Sqrt(n) algorithmSqrt(n) algorithm
Sqrt(n) algorithm승혁 조
 
DP Optimization
DP OptimizationDP Optimization
DP Optimization승혁 조
 
Tree algorithm
Tree algorithmTree algorithm
Tree algorithm승혁 조
 
05. network flow 2
05. network flow 205. network flow 2
05. network flow 2승혁 조
 
05 divide and conquer
05 divide and conquer05 divide and conquer
05 divide and conquer승혁 조
 
04. network flow 1
04. network flow   104. network flow   1
04. network flow 1승혁 조
 
04. binary search
04. binary search04. binary search
04. binary search승혁 조
 
02. binary search tree
02. binary search tree02. binary search tree
02. binary search tree승혁 조
 

More from 승혁 조 (20)

RSS Live Slider
RSS Live SliderRSS Live Slider
RSS Live Slider
 
Parallel binary search
Parallel binary searchParallel binary search
Parallel binary search
 
Geometry Algorithms
Geometry AlgorithmsGeometry Algorithms
Geometry Algorithms
 
FFT
FFTFFT
FFT
 
Heavy light decomposition
Heavy light decompositionHeavy light decomposition
Heavy light decomposition
 
Advanced segment tree
Advanced segment treeAdvanced segment tree
Advanced segment tree
 
L-R network flow
L-R network flowL-R network flow
L-R network flow
 
MCMF
MCMFMCMF
MCMF
 
Sqrt(n) algorithm
Sqrt(n) algorithmSqrt(n) algorithm
Sqrt(n) algorithm
 
DP Optimization
DP OptimizationDP Optimization
DP Optimization
 
NIM game
NIM gameNIM game
NIM game
 
DP 중급 2
DP 중급 2DP 중급 2
DP 중급 2
 
Tree algorithm
Tree algorithmTree algorithm
Tree algorithm
 
Number theory
Number theoryNumber theory
Number theory
 
06. sorting
06. sorting06. sorting
06. sorting
 
05. network flow 2
05. network flow 205. network flow 2
05. network flow 2
 
05 divide and conquer
05 divide and conquer05 divide and conquer
05 divide and conquer
 
04. network flow 1
04. network flow   104. network flow   1
04. network flow 1
 
04. binary search
04. binary search04. binary search
04. binary search
 
02. binary search tree
02. binary search tree02. binary search tree
02. binary search tree
 

분할정복

  • 1. By POSTECH Computer Algorithm Team 분할정복 남진환 Dvide & Conquer
  • 2. Contents POSTECH Computer Algorithm Team Master Theorem 05 분할정복 03 FENCE 08 문제 18
  • 3. POSTECH Computer Algorithm Team 분할정복의 가장 기본적인 아이디어는, 어떤 문제를 풀기 위해 그 문제를 여러 개로 나누어서 푼 후, 그 해답을 합 쳐서 최종적인 해답을 도출하는 것이다. 포스텍에서 가장 키가 큰 사람을 찾기 위해 각 학번마다 키가 가장 큰 사람을 찾아내서 비교하고, 각 학번에서 키 가 가장 큰 사람을 찾기 위해 동일 학번내의 각 분반에서 키가 가장 큰 사람을 찾아내서 비교한다면 분할정복의 아 이디어를 사용한 것이다. 분할정복
  • 4. POSTECH Computer Algorithm Team 분할정복은 다음과 같은 때에 주로 사용된다. 1. 주어진 문제가 조금 더 작은 범위인 여러 개의 같은 문제로 나뉠 수 있을 때 2. 각 소문제가 대문제와 근본적으로 동일한 재귀적 방법으로 해결될 때 3. 각 소문제들의 해답을 합침으로써 대문제를 풀 수 있을 때 분할정복
  • 5. POSTECH Computer Algorithm Team 마스터 정리는, 문제를 재귀적으로 푸는 알고리즘의 시간 복잡도를 간단하게 구하는 방법이다. 모든 재귀적 알고리즘의 시간 복잡도를 구할 수 있는 것은 아니지만, 상당히 유용하게 쓰인다. 길이 N의 문제를 푸는데에 T(N)이 걸린다고 하자. 이때, T(N)은 T(N) = aT( 𝑁 𝑏 ) + 𝑓(𝑁) 이라는 점화식을 만족한다. (a > 0, b > 1) 그렇다면, T(N) ∈ O(𝑁log 𝑏 𝑎 ) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 − 𝜀 ) for some constant 𝜀 > 0 O(𝑁log 𝑏 𝑎 log 𝑁) 𝑖𝑓 𝑓 𝑁 ∈ O(𝑁log 𝑏 𝑎 ) O(f(N)) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 + 𝜀 ) 이고 충분히 큰 N과 1보다 큰 c에 대해 af( 𝑁 𝑏 ) ≤ 𝑐𝑓 𝑁 Master Theorem
  • 6. POSTECH Computer Algorithm Team Master Theorem의 직관적인 설명 g(n) = 𝑛log 𝑏 𝑎 라 할 때, 1. g(n)이 더 무거우면 g(n)이 시간 복잡도를 결정한다 2. g(n)과 f(n)의 무게가 같다면 g(n)에 log 𝑛 을 곱한 것이 시간 복잡도이다 3. f(n)이 더 무거우면 f(n)이 시간 복잡도를 결정한다 Master Theorem https://blog.naver.com/yyj9301/221240585554
  • 7. POSTECH Computer Algorithm Team Master Theorem
  • 8. POSTECH Computer Algorithm Team 히스토그램은 직사각형 여러 개가 아래쪽으로 정렬되어 있는 도형이다. 각 직사각형은 같은 너비를 가지고 있지만, 높이는 서로 다를 수도 있다. 예를 들어, 왼쪽 그림은 높이가 2, 1, 4, 5, 1, 3, 3이고 너비가 1인 직사각형으로 이 루어진 히스토그램이다. 히스토그램에서 가장 넓이가 큰 직사각형을 구하는 프로그램을 작성하시오. FENCE https://algospot.com/judge/problem/read/FENCE
  • 10. POSTECH Computer Algorithm Team - 무식하게 푼다면 O(𝑁2 )이 걸린다! - 분할정복: 나눈다 -> 푼다 -> 합친다 이 문제에서, 나누는 것은 히스토그램을 왼쪽 오른쪽으로 나누는 것이고 푸는 것은 왼쪽과 오른쪽의 히스토그램에서 가장 큰 직사각형의 넓이를 구하는 것이다 그렇다면 합치는 것은? 왼쪽과 오른쪽의 최댓값을 비교하기만 하면 안된다. 왼쪽 부분과 오른쪽 부분의 히스토그램을 모두 사용할 때의 최댓값도 구해야한다! FENCE
  • 11. POSTECH Computer Algorithm Team FENCE 먼저, 왼쪽과 오른쪽 부분이 모두 포함되어야 하기 때문에 중앙의 두 막대를 포함하고 시작한다.
  • 12. POSTECH Computer Algorithm Team FENCE 그 다음, 선택된 막대의 왼쪽과 오른쪽 막대의 높이를 비교한다. 그 중 높이가 더 큰 막대를 선택한다.
  • 14. POSTECH Computer Algorithm Team FENCE 다시, 선택된 막대의 왼쪽과 오른쪽 막대 중 높이가 더 큰 것을 선택한다.
  • 15. POSTECH Computer Algorithm Team FENCE 이와 같은 행위를 반복하면, 왼쪽과 오른쪽 부분을 동시에 사용하며 넓이가 가장 큰 직사각형을 찾을 수 있다. 여기서, 합치는 과정의 시간 복잡도는 O(N)이다.
  • 16. POSTECH Computer Algorithm Team 이와 같은 방법으로, 우리는 문제를 해결할 수 있다. - 그렇다면 이 알고리즘의 시간 복잡도는? 길이 N짜리 문제를 풀기 위해서는 길이 𝑁 2 짜리 문제를 2개 풀어야 하고, 합치는 과정에서 N만큼의 시간이 필요하다. 길이 𝑁 2 짜리 문제를 풀기 위해서는 길이 𝑁 4 짜리 문제를 2개 풀어야 하고, 합치는 과정에서 𝑁 2 만큼의 시간이 필요하다. 길이 𝑁 4 짜리 문제를 풀기 위해서는 . . . Master Theorem을 적용해보자! FENCE
  • 17. POSTECH Computer Algorithm Team 문제에서, T(N) = 2T( 𝑁 2 ) + 𝑁 Master Theorem에서 a = 2, b = 2, f(N) = N인 경우이다. 조건에 대입해보자. T(N) ∈ O(𝑁log 𝑏 𝑎 ) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 − 𝜀 ) for some constant 𝜀 > 0 O(𝑁log 𝑏 𝑎 log 𝑁) 𝑖𝑓 𝑓 𝑁 ∈ O(𝑁log 𝑏 𝑎 ) O(f(N)) 𝑖𝑓 𝑓 𝑁 ∈ 𝑂(𝑁log 𝑏 𝑎 + 𝜀 ) 이고 충분히 큰 N과 1보다 큰 c에 대해 af( 𝑁 𝑏 ) ≤ 𝑐𝑓 𝑁 f(N) ∈ O(N)이고 log 𝑏 𝑎 = 1 이므로 가운데에 해당된다. => T(N) ∈ (NlogN) FENCE
  • 18. POSTECH Computer Algorithm Team https://algospot.com/judge/problem/read/QUADTREE - QUADTREE https://algospot.com/judge/problem/read/FENCE – FENCE https://www.acmicpc.net/problem/2751 – Merge Sort https://algospot.com/judge/problem/read/FANMEETING - FANMEETING https://www.acmicpc.net/problem/1992 - 쿼드트리의 이해를 돕기 위한 문제 문제 풀기