computer algorithm 실습 - backtracking, greedy method -

Post on 22-Feb-2016

193 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Computer Algorithm 실습 - Backtracking, Greedy Method -. Kim Hwan- Hee (hwanhee0920@kangwon.ac.kr) 2013. 5. 20. < 목 차 >. Backtracking( 되추적 ) – Graph Coloring 알고리즘 설명 프로그래밍 실습 Greedy Method( 탐욕적인 방법 ) – Prim Algorith m 알고리즘 설명 프로그래밍 실습 알고리즘 HW #2. 1. Backtracking – Graph Coloring. - PowerPoint PPT Presentation

TRANSCRIPT

1

Computer Algorithm 실습- Backtracking, Greedy Method -

Kim Hwan-Hee(hwanhee0920@kangwon.ac.kr)

2013. 5. 20.

2

< 목 차 >

• Backtracking( 되추적 ) – Graph Coloring

1) 알고리즘 설명2) 프로그래밍 실습

• Greedy Method( 탐욕적인 방법 ) – Prim Algorithm

1) 알고리즘 설명2) 프로그래밍 실습

• 알고리즘 HW #2

3

1. Backtracking – Graph Coloring

• Graph Coloring Algorithm Overview1) m 개의 색을 가지고 , 인접한 지역이 같은 색이 되지 않도록 지도에

색칠하는 문제2) 위와 같은 그래프에서 2 가지 색은 불가능3) 3 가지 색은 총 6 가지 방법 가능

4

1. Backtracking – Graph Coloring

• Graph Coloring Algorithm ( 1/2 )1) 입력 : n – 노드의 수 , m – 색깔의 수 , W[i][j] – 이음선 있으면 true, 그렇지 않으면 false2) 출력 : vcolor[i] - i 번째 노드에 할당된 색 (1 ~ m) 이다 .

5

1. Backtracking – Graph Coloring

• Graph Coloring Algorithm ( 2/2 )

6

1. Backtracking – Graph Coloring

• Graph Coloring Programming ( 1/3 )

7

1. Backtracking – Graph Coloring

• Graph Coloring Programming ( 2/3 )

8

1. Backtracking – Graph Coloring

• Graph Coloring Programming ( 3/3 )

9

1. Backtracking – Graph Coloring

• Graph Coloring Result1) 색의 수를 3 가지로 하였을 때의 결과는 다음과 같다 .

10

2. Greedy Method – Prim Algo-rithm

• Prim Algorithm Overview ( 1/2 )1) 문제 : 비방향성 그래프 G = (V,E) 가 주어졌을 때 , F E 를 만족하면서 , (V,F)

가 G 의 MST 가 되는 F 를 찾는 문제 .

2) 그래프의 인접행렬식 표현

3) 추가적으로 nearest[1..n] 과 distance[1..n] 배열 유지① nearest[i] = Y 에 속한 노드 중 vi(V-Y) 에서 가장 가까운 노드의 인덱스 ② distance[i] = vi 와 nearest[i] 를 잇는 이음선의 가중치

11

2. Greedy Method – Prim Algo-rithm• Prim Algorithm Overview ( 2/2 )

1) 그래프의 인접행렬식 표현v1 v2

v3 v4

v5

1

3 3

4

2 5

6

12

2. Greedy Method – Prim Algo-rithm• Prim Algorithm ( 1/2 )

13

2. Greedy Method – Prim Algo-rithm• Prim Algorithm ( 2/2 )

14

2. Greedy Method – Prim Algo-rithm• Prim Programming

15

2. Greedy Method – Prim Algo-rithm• Prim Result

16

3. HW #2

• 앞서 Greedy Method 와 Backtracking Algorithm 을 한 가지씩 살펴보았습니다 .

1) Greedy Method – Prim Algorithm

2) Backtracking – Graph Coloring

• Greedy Method 방법과 Backtracking Algorithm 의 실습을 위해 한 가지씩 프로그래밍을 더 수행하세요 .

1) Greedy Method – Dijkstra Algorithm

2) Backtracking – nQueens Problem ( n = 4 일 때 )

17

top related