Greedy Method Minimum Spanning Tree Dijkstras Algorithm for
- Slides: 57
강의 순서 Greedy Method 탐욕적 알고리즘 개요 최소비용 신장 트리 (Minimum Spanning Tree) Dijkstra’s Algorithm for the Short Path Problem 배낭 채우기 문제 (The Knapsack Problem) 2 Computer Algorithms by Yang-Sae Moon
강의 순서 Greedy Method 탐욕적 알고리즘 개요 최소비용 신장 트리 (Minimum Spanning Tree) Dijkstra’s Algorithm for the Short Path Problem 배낭 채우기 문제 (The Knapsack Problem) 7 Computer Algorithms by Yang-Sae Moon
연결된 가중치 (포함) 비방향 그래프 Greedy Method v 1 1 v 2 3 3 6 4 v 3 v 4 5 2 v 5 9 Computer Algorithms by Yang-Sae Moon
신장 트리의 예 Greedy Method v 1 1 v 2 3 6 v 4 v 3 5 v 5 11 Computer Algorithms by Yang-Sae Moon
강의 순서 Greedy Method 탐욕적 알고리즘 개요 최소비용 신장 트리 (Minimum Spanning Tree) l Prim의 알고리즘 l Kruskal의 알고리즘 Dijkstra’s Algorithm for the Short Path Problem 배낭 채우기 문제 (The Knapsack Problem) 16 Computer Algorithms by Yang-Sae Moon
MST – Prim의 알고리즘(구체적) (1/3) Greedy Method 그래프의 인접행렬식 표현 추가적으로 nearest[1. . n]과 distance[1. . n] 배열 유지 • nearest[i] = Y에 속한 노드 중에서 vi에서 가장 가까운 노드의 인덱스 • distance[i] = vi와 nearest[i]를 잇는 이음선의 가중치 Y wa, b va nearest[a] = b distance[a] = wa, b vj vb vi nearest[i] = j distance[i] = wi, j 19 Computer Algorithms by Yang-Sae Moon
MST – Prim의 알고리즘(구체적) (2/3) Greedy Method 알고리즘 void prim(int n, // 입력: 정점의 수 const number W[][], // 입력: 그래프의 인접행렬식 표현 set_of_edges& F) // 출력: 그래프의 MST에 속한 이음선의 집합 { index i, vnear; number min; edge e; index nearest[2. . n]; number distance[2. . n]; F = empty_set; for(i=2; i <= n; i++) { // 초기화 nearest[i] = 1; // 초기에는 Y에 노드가 v 1밖에 없음 distance[i] = W[1][i]; // (vi, v 1)의 가중치로 초기화 } // see the next page 20 Computer Algorithms by Yang-Sae Moon
MST – Prim의 알고리즘(구체적) (3/3) Greedy Method 알고리즘 (계속) repeat(n-1 times) { // n-1개의 정점을 Y에 차례로 추가한다 min = “infinite”; for(i=2; i <= n; i++) { // 각 정점에 대해서 if (0 <= distance[i] < min) { // distance[i]를 검사하여 min = distance[i]; // 가장 가까이 있는 vnear을 vnear = i; // 찾는다. } } e = vnear와 nearest[vnear]를 잇는 이음선; e를 F에 추가; distance[vnear] = -1; // 찾은 노드를 Y에 추가한다. for(i=2; i <= n; i++) if (W[i][vnear] < distance[i]) { // Y에 없는 각 노드에 대해서 distance[i] = W[i][vnear]; // distance[i]와 nearest[i] = vnear; // nearest[i]를 갱신한다. } } // end of repeat } // end of main 21 Computer Algorithms by Yang-Sae Moon
강의 순서 Greedy Method 탐욕적 알고리즘 개요 최소비용 신장 트리 (Minimum Spanning Tree) l Prim의 알고리즘 l Kruskal의 알고리즘 Dijkstra’s Algorithm for the Short Path Problem 배낭 채우기 문제 (The Knapsack Problem) 28 Computer Algorithms by Yang-Sae Moon
MST – More Improved Algorithms Greedy Method 알고리즘의 시간복잡도는 그 알고리즘을 구현하는데 사용하는 자 료구조에 좌우되는 경우도 있다. 35 Computer Algorithms by Yang-Sae Moon
강의 순서 Greedy Method 탐욕적 알고리즘 개요 최소비용 신장 트리 (Minimum Spanning Tree) Dijkstra’s Algorithm for the Short Path Problem 배낭 채우기 문제 (The Knapsack Problem) 36 Computer Algorithms by Yang-Sae Moon
Dijkstra 알고리즘 – 구성 예제 39 Greedy Method Computer Algorithms by Yang-Sae Moon
Dijkstra 알고리즘 (세부적) (2/3) Greedy Method 알고리즘 void dijkstra(int n, const number W[][], set_of_edges& F) { index i, vnear; number min; edge e; index touch[2. . n]; number length[2. . n]; F = empty_set; for(i=2; i <= n; i++) { // 초기화 touch[i] = 1; // 초기에는 Y에 노드가 v 1밖에 없음 length[i] = W[1][i]; // (v 1, vi)의 가중치로 초기화 } // see the next page 41 Computer Algorithms by Yang-Sae Moon
강의 순서 Greedy Method 탐욕적 알고리즘 개요 최소비용 신장 트리 (Minimum Spanning Tree) Dijkstra’s Algorithm for the Short Path Problem 배낭 채우기 문제 (The Knapsack Problem) 44 Computer Algorithms by Yang-Sae Moon
Dynamic Programming vs. Greedy Method 45 Greedy Method Computer Algorithms by Yang-Sae Moon
Homework #3 Greedy Method 57 Computer Algorithms by Yang-Sae Moon
- Minimum leaf spanning tree
- Minimum cost spanning tree
- Lazy prim's algorithm
- Dijkstra's algorithm proof
- Minimum spanning tree definition
- Minimum spanning tree shortest path
- Minimum spanning tree
- Minimum spanning tree weighted graph
- Minimum spanning tree
- Solin algorithm
- Minimum spanning tree
- Minimum spanning tree
- Minimum spanning tree
- Minimum spanning tree
- Spanning tree algorithm in computer networks
- Minimum spanning set
- Common spanning tree
- Spanning tree definition
- Spanning tree
- Contoh soal pohon berakar
- Protocolo spanning tree
- Udld normal vs aggressive
- Pohon berakar yang urutan anak-anaknya penting disebut
- Spanning tree of a graph
- Spanning tree of a graph
- Stp protocol explained
- Stp convergence
- Spanning tree tutorial
- Bfs spanning tree
- Degree constrained spanning tree
- Asus spanning tree protocol
- Absolute maximum and minimum
- The greedy snake
- What is greedy method
- Greedy algorithm
- Advantage and disadvantage of greedy algorithm
- Activity selection problem greedy algorithm example
- Greedy activity selector
- Greedy interval partitioning
- Greedy algorithms
- Activity selection problem greedy algorithm
- Greedy algorithm for job sequencing with deadlines
- Knapsack method
- Why is huffman coding greedy
- Greedy vs dynamic programming
- What is greedy choice property
- N/a greedy
- Dynamic programming vs divide and conquer
- 4greedy
- Coin change problem greedy algorithm proof
- Greedy algorithm for 0-1 knapsack problem
- Greedy algorithm time complexity
- Greedy algorithm
- General principle of greedy algorithm
- Huffman coding greedy algorithm
- Greedy algorithm definition
- Amihood amir
- Pairwise exchange method