This document discusses parallel binary search. It divides a problem space from minimum to maximum into multiple sub-ranges that can be searched in parallel. The sub-ranges are (min, h), (h, h2), and (h2, max) where h and h2 are splitting points. Each processor then performs binary search on one sub-range independently. This allows the queries to be handled more quickly by searching multiple parts of the problem space in parallel rather than sequentially.
This document discusses algorithms and geometry. It covers the Postech Computer Algorithm Team and convex hulls. The Postech team works on algorithms and geometry problems. Convex hull concepts are explained, including finding the farthest point and defining a convex polygon. Formulas for computing areas and determining if a point is inside a convex shape are provided.
The document discusses the Fast Fourier Transform (FFT) algorithm and its use for multiplying two polynomials. It explains that FFT uses the Fourier transform to break down the polynomial multiplication problem into smaller subproblems by mapping the polynomials to the frequency domain using the Discrete Fourier Transform (DFT). It then describes the Cooley-Tukey algorithm, which is an efficient method for computing the DFT and allows FFT to multiply two polynomials in O(n log n) time rather than O(n^2) time for the standard multiplication approach.
The document discusses segment tree data structures for storing interval data. It describes persistent and dynamic segment trees, which allow maintaining interval data over time as the data is updated. The segment trees support operations like querying the total value in an interval or updating the value of an interval efficiently in logarithmic time.
The document describes a network flow algorithm. It involves modeling the network as a flow graph with nodes and edges having capacities and costs. The algorithm finds the maximum flow from a source to a sink in the graph while minimizing the total cost of the flow. It works by scaling all edge costs and finding augmenting paths with negative reduced costs to increment the flow over each path.
This document discusses parallel binary search. It divides a problem space from minimum to maximum into multiple sub-ranges that can be searched in parallel. The sub-ranges are (min, h), (h, h2), and (h2, max) where h and h2 are splitting points. Each processor then performs binary search on one sub-range independently. This allows the queries to be handled more quickly by searching multiple parts of the problem space in parallel rather than sequentially.
This document discusses algorithms and geometry. It covers the Postech Computer Algorithm Team and convex hulls. The Postech team works on algorithms and geometry problems. Convex hull concepts are explained, including finding the farthest point and defining a convex polygon. Formulas for computing areas and determining if a point is inside a convex shape are provided.
The document discusses the Fast Fourier Transform (FFT) algorithm and its use for multiplying two polynomials. It explains that FFT uses the Fourier transform to break down the polynomial multiplication problem into smaller subproblems by mapping the polynomials to the frequency domain using the Discrete Fourier Transform (DFT). It then describes the Cooley-Tukey algorithm, which is an efficient method for computing the DFT and allows FFT to multiply two polynomials in O(n log n) time rather than O(n^2) time for the standard multiplication approach.
The document discusses segment tree data structures for storing interval data. It describes persistent and dynamic segment trees, which allow maintaining interval data over time as the data is updated. The segment trees support operations like querying the total value in an interval or updating the value of an interval efficiently in logarithmic time.
The document describes a network flow algorithm. It involves modeling the network as a flow graph with nodes and edges having capacities and costs. The algorithm finds the maximum flow from a source to a sink in the graph while minimizing the total cost of the flow. It works by scaling all edge costs and finding augmenting paths with negative reduced costs to increment the flow over each path.
This document discusses concepts in number theory and combinatorics from the POSTECH Computer Algorithm Team. It covers topics like prime numbers, factorization, and counting principles. Example problems and their solutions are provided to illustrate concepts in number theory like finding the greatest common divisor and factoring numbers.
This document discusses concepts in number theory and combinatorics from the POSTECH Computer Algorithm Team. It covers topics like prime numbers, factorization, and counting principles. Example problems and their solutions are provided to illustrate concepts in number theory like finding the greatest common divisor and factoring numbers.
3. POSTECH Computer Algorithm Team
Concept
Ford-Fulkerson Algorithm 리뷰
- Flow Graph에서 source에서 sink로 가는 경로를 찾는다.
- 가능할 때까지 그 경로에 Flow를 흘려준다.
- 흘려준 Flow 양만큼 Back Edge를 만들어준다.
- 더 이상 흘려줄 수 없을 때까지 반복한다.
- 이게 Maximum Flow인가?
Proof of Ford-Fulkerson
4. POSTECH Computer Algorithm Team
Concept
Cut으로 설명할 수 있다!
- Cut : Weight Graph에서 Graph를 등분하기 위한 cost
- 점 S,E가 주어진다.
- 이때, 임의의 Weight Edge를 그래프 G에서 제거한다. 이때 드는 cost는 Edge의 Weight와 같다.
- S에서 E로 가는 Path가 없으면 된다.
- Minimum Cut Problem : 가장 적은 cost로 Cut을 만드는 방법은 무엇일까?
Proof of Ford-Fulkerson
6. POSTECH Computer Algorithm Team
Concept
- 기본적으로 Cut과 Flow는 관계가 없다.
- Flow는 Flow Graph, Cut은 Weight Graph에서 생각하기 때문
- 그래서 Flow Graph에 Weight를 준다.
- Flow Graph (u, v, c)는 Weight c를 가진다. 즉, Edge를 없애려면 Capacity만큼의 cost를 지불해야 한다.
- Flow Graph의 Source, Sink를 Cut의 S와 E로 설정한다.
- 그렇다면, 이 Flow Graph의 Maximum Flow는 Minimum Cut이랑 값이 같다!! (매우중요)
Proof of Ford-Fulkerson
7. POSTECH Computer Algorithm Team
Concept
1. Maximum Flow >= Minimum Cut
- 만약 Graph G에 Maximum Flow가 흐른다고 가정하자.
- 집합 S, T를 생각하자. v가 S에 속해있다는 것 if and only if는 Graph G에서 Source는 그대로, Sink를 v로 설정
하였을 때 Flow가 1 이상이란 것이다.
- Source도 S에 속해있다고 둔다.
- T는 S의 여집합이다. 즉, T = V – S
- G가 Maximum Flow를 가지고 있으므로, sink는 T에 속하게 된다. 아니면 G는 Maximum Flow가 아니다.
Maximum Flow – Min Cut
8. POSTECH Computer Algorithm Team
Concept
- S에서 T로 가는 Edge들은 Capacity = Flow를 만족한다.
- 아닐 경우, S와 T의 정의에 모순.
- T에서 S로 가는 Edge들은 Flow = 0이다.
- 아닐 경우, S와 T의 정의에 모순.
- S와 T는 V의 partition이고 S는 source를, T는 sink를 가지고 있으므로 Cut이다.
- 이때, cost는 S에서 T로 가는 모든 Capacity의 합이고 이는 Maximum Flow의 값과 같다.
- 따라서, Minimum Cost의 정의에 의해 Maximum Flow >= Minimum Cost다.
Maximum Flow – Min Cut
9. POSTECH Computer Algorithm Team
Concept
2. Minimum Cut >= Maximum Flow
- 그래프 G가 Minimum Cut을 가지고 있다고 하자. 이때, Source가 있는 쪽을 S, Sink가 있는 쪽을 T라고 하고, 잘
린 Edge들을 E1, E2, … , Ek라고 하자.
- 원래 Graph G에서 Flow를 흘려준다 할 때, Ei들을 만드시 지나야 한다.
- Ei를 지나는 모든 Flow의 합을 Fi라고 해보자. Fi는 Ci보다 같거나 작다. (Ci = Ei의 Capacity)
Maximum Flow – Min Cut
10. POSTECH Computer Algorithm Team
Concept
- Source에서 Sink로 가는 모든 Flow Path를 F1, F2, … , Fn이라고 하자.
- 이때, F1, … , Fn을 k개의 Partition P1, P2, … , Pk로 나눌 수 있다.
- Fi가 Pj에 속해있다는 말은, Path Fi안에 Ej가 속해있다는 뜻이다.
- Pj에 속해있는 모든 Flow의 합은 Cj보다 같거나 작다.
- 따라서 모든 Flow의 합은 C1 + C2 + … + Ck보다 같거나 작다.
- C1 + C2 + … + Ck는 Minimum Cut cost다.
- 따라서, Minimum Cut >= Maximum Flow
앞에서 Minimum Cut <= Maximum Flow임을 증명하였다. 따라서 Minimum Cut = Maximum Flow임이 증명된다.
Maximum Flow – Min Cut
11. POSTECH Computer Algorithm Team
Concept
- Ford-Fulkerson Algorithm으로 돌아가자.
- Ford-Fulkerson Algorithm은 Maximum Flow를 찾는다!
- Graph G의 Minimum Cut이 있다고 하자.
- Ford-Fulkerson로 더 이상 Flow를 흘려줄 수 없을 때까지 흘려주면, 그것은 Cut이 된다.(By Definition of Cut)
- 따라서, Ford-Fulkerson >= Minimum Cut (Minimum Cut은 모든 Cut보다 작다.)
- 그리고 Ford-Fulkerson의 모든 결과는 Flow다.
- 따라서, Ford-Fulkerson <= Maximum Flow (Maximum Flow는 모든 Flow보다 크다.)
Proof of Ford-Fulkerson
12. POSTECH Computer Algorithm Team
Concept
- 따라서, Minimum Cut <= Ford-Fulkerson <= Maximum Flow
- Minimum Cut = Maximum Flow이므로, Ford-Fulkerson = Maximum Flow = Minimum Cut
- Ford-Fulkerson은 항상 Maximum Flow를 잘 찾는다.
Proof of Ford-Fulkerson
13. POSTECH Computer Algorithm Team
Concept
- Graph G를 S와 T로 나눌 수 있을 때, Bipartite Graph라 한다.
- 만약 임의의 vertex u, v가 S에 속하면, (u, v)라는 Edge는 존재하지 않는다.
- 만약 임의의 vertex u, v가 T에 속하면, (u, v)라는 Edge는 존재하지 않는다.
- 즉, 모든 Edge는 S와 T사이에 있으며 S와 S, T와 T사이를 잇는 Edge는 존재하지 않는다.
Bipartite Matching
14. POSTECH Computer Algorithm Team
Concept
- Matching : 집합 A에서 임의의 조건을 만족하는 두 element u, v를 고를 때, 이를 Matching이라고 한다.
- Graph에서 Matching : Edge들을 고를 것인데, 모든 Vertex는 최대 1개의 선택된 Edge에만 속해야 한다.
- Maximum Matching : 이렇게 Edge들을 고를 때 최대한 Edge를 많이 선택하는 Matching
- Bipartite Maximum Matching : Bipartite Graph에서 Maximum Matching을 하는 것.
Bipartite Matching
15. POSTECH Computer Algorithm Team
Concept
- Bipartite Matching은 Flow 문제로 바꿀 수 있다!
- Graph G에서, 모든 Edge가 Capacity 1을 가진다고 하자.
- Source, Sink를 만들어서, Source를 S의 모든 vertex와, Sink를 T의 모든 vertex와 연결한다. (Capacity 1)
- Flow를 계산하면, Bipartite Maximum Matching이 된다.
- 왜?
Bipartite Matching
16. POSTECH Computer Algorithm Team
Concept
- S에서 T로 가는 Edge들 중, Flow가 흐르는 Edge를 생각해 보자.
- Edge (u, v)에 Flow가 흐른다면, u와 v는 반드시 이 Edge에만 속하게 된다. 왜냐하면, Source에서 u, v에서 Sink
로 가는 Edge의 Capacity가 1이기 때문이다.
- 만약 u가 E1, E2에 동시에 속해 있다면, u로 가는 Flow값은 최소 2 이상이여야 한다. 이는 모순이다!
- 만약, Maximum Flow 이상의 Bipartite Matching이 존재한다면, 그 값이 Maximum Flow여야 한다.
- 따라서, Maximum Flow = Bipartite Matching
Bipartite Matching
17. POSTECH Computer Algorithm Team
Concept
- Bipartite Matching을 Ford-Fulkerson으로 실행하면 O(fE)의 시간이 나온다.
- Maximum Flow는 V를 넘을 수 없다. 따라서, O(VE)로 실행된다.
- Dinic Algorithm을 이용하여 Flow를 계산하면 O(V^2E)
- 하지만, Dinic Algorithm은 모든 Edge가 Unit Capacity(only 1)을 가지면 O(min(V^2/3 , E^1/2)E)로 동작한다.
- 즉, Dinic을 이용하여 Flow를 계산하면 O(E^3/2)
Bipartite Matching
18. POSTECH Computer Algorithm Team
Concept
- L-R Maximum Flow : Edge에 Capacity와 함께 Demand도 주어진다. 모든 Edge에는 Demand이상의 Flow가 흘러야한다.
- Gomory-Hu Tree : Graph가 고정되고, source와 sink가 임의로 변할 때, 모든 쌍에 대한 Flow 계산
- Min-Cost Max-Flow : Edge에 Capacity와 함께 Weight가 주어진다. Maximum Flow를 가지는 모든 Path들의 Weight
합이 최소가 되게 해야한다.
- Weighted Bipartite Maximum Matching : Bipartite Graph에 Weight가 주어진다. Maximum Matching중 최소 Weight
합을 구하는 Matching을 찾아야 한다.
- Hungarian Method
Special Case of Flow Graph
19. POSTECH Computer Algorithm Team
More
- Maximum Flow = Minimum Cut임을 증명하시오
- Ford-Fulkerson이 Maximum Flow를 가짐을 보이시오.
- Dinic Algorithm을 적고, Maximum Flow를 가짐을 보이시오.
- https://www.acmicpc.net/problem/1014
- https://www.acmicpc.net/problem/1017
- https://www.acmicpc.net/problem/1760
- https://www.acmicpc.net/problem/1671