DA20 - B.B Karki LSU 0.1 CSC 3102 Algorithm Design...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: B.B. Karki, LSU 0.1 CSC 3102 Algorithm Design Techniques Brute force Divide-and-conquer Decrease-and-conquer Transform-and-conquer Space-and-time tradeoffs Dynamic programming Greedy techniques B.B. Karki, LSU 0.2 CSC 3102 Greedy Techniques B.B. Karki, LSU 0.3 CSC 3102 Basics Constructing a solution to an optimization problem through a sequence of steps, each expanding a partially constructed solution obtained so far, until a complete solution to the problem is reached. On each step, the choice made must be feasible, locally optimal and inrevocable. Examples: Constructing a minimum spanning tree (MST) of a weighted connected graph Grows a MST through a greedy inclusion of the nearest vertex or shortest edge to the tree under construction Prim’s and Kruskal’s algorithms Solving the single-source shortest-path problem Finds shortest paths from a given vertex (the source) to all other vertices. Dijkstra’s algorithm Huffman tree and code A binary tree that minimizes the weighted path length from the root to the leaves containing a set of predefined weights An optimal prefix-free variable-length encoding scheme. B.B. Karki, LSU 0.4 CSC 3102 Minimum Spanning Tree B.B. Karki, LSU 0.5 CSC 3102 MST: Problem Statement Given n points, connect them in the cheapest possible way so that there will be a path between every pair of points Graph representation, e.g., a network Solve the minimum spanning tree problem. A spanning tree of a connected graph is its connected acyclic subgraph (a tree) that contains all its vertices. A minimum spanning tree of a weighted connected graph is its spanning tree of the smallest weight. The weight of a tree is the sum of the weights on all its edges Sum of the lengths of all edges If the edge weights are unique, then there will be only one minimum spanning tree otherwise more than one MST exist. a b d 5 3 2 9 1 7 A complete graph on four vertices Many spanning trees are possible a c b d 3 2 1 A minimum spanning tree with W = 6 a c b d 5 3 1 a b d 9 1 7 W = 9 W = 17 c c B.B. Karki, LSU 0.6 CSC 3102 Constructing a MST Exhaustive search approach: List all spanning trees and find the one with the minimum weight from the list The number of spanning trees grows exponentially with the graph size Efficient algorithms for finding a MST for a connected weighted graph Prim’s algorithm (R.C. Prim, 1957) Constructs a MST one vertex at a time by including the nearest vertex to the vertices already in the tree Kruskal’s algorithm (J.B. Kruskal, 1956) Constructs a MST one edge at a time by selecting edges in increasing order of their weights provided that the inclusion does not create a cycle. B.B. Karki, LSU 0.7 CSC 3102 Prim’s Algorithm Constructs a MST through a sequence of expanding subtrees The initial subtree ( V T ) in such a sequence consists of a single vertex selected arbitrarily from the set...
View Full Document

This note was uploaded on 10/06/2009 for the course CSC 3102 taught by Professor Kraft,d during the Fall '08 term at LSU.

Page1 / 28

DA20 - B.B Karki LSU 0.1 CSC 3102 Algorithm Design...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online