Lecture 26 CSE 331 Nov 2, 2016.

Slides:



Advertisements
Similar presentations
O(N 1.5 ) divide-and-conquer technique for Minimum Spanning Tree problem Step 1: Divide the graph into  N sub-graph by clustering. Step 2: Solve each.
Advertisements

Lecture 26 CSE 331 Nov 4, The week of Nov 16 Jeff will be out of town for a conference Recitations and office hour cancelled for that week Two extra.
Lecture 28 CSE 331 Nov 9, Flu and HW 6 Graded HW 6 at the END of the lecture If you have the flu, please stay home Contact me BEFORE you miss a.
Lecture 27 CSE 331 Nov 3, Combining groups Groups can unofficially combine in the lectures.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Design and Analysis of Algorithms Minimum Spanning trees
Lecture 25 CSE 331 Nov 2, Adding teeth to group talk Form groups of size at most six (6) Pick a group leader I will ask group leader(s) to come.
Lecture 28 CSE 331 Nov 5, HW 7 due today Q1 in one pile and Q 2+3 in another I will not take any HW after 1:15pm.
Lecture 30 CSE 331 Nov 10, Online Office Hours
Lecture 27 CSE 331 Nov 6, Homework related stuff Solutions to HW 7 and HW 8 at the END of the lecture Turn in HW 7.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
SPANNING TREES Lecture 21 CS2110 – Spring
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Lecture 28 CSE 331 Nov 9, Mini project report due WED.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
Minimum- Spanning Trees
CSCI 256 Data Structures and Algorithm Analysis Lecture 10 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Merge Sort 1/12/2018 5:48 AM Merge Sort 7 2   7  2  2 7
COMP108 Algorithmic Foundations Greedy methods
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Lecture 32 CSE 331 Nov 16, 2016.
Lecture 31 CSE 331 Nov 14, 2016.
Lecture 22 Minimum Spanning Tree
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Lecture 31 CSE 331 Nov 13, 2017.
Data Structures & Algorithms Graphs
Minimum Spanning Tree.
Lecture 24 CSE 331 Oct 28, 2016.
Lecture 24 CSE 331 Oct 27, 2017.
Lecture 33 CSE 331 Nov 18, 2016.
Lecture 30 CSE 331 Nov 11, 2016.
Lecture 26 CSE 331 Nov 1, 2017.
Lecture 27 CSE 331 Nov 3, 2017.
Chapter 23 Minimum Spanning Tree
Richard Anderson Lecture 11 Minimum Spanning Trees
Lecture 26 CSE 331 Nov 2, 2012.
Autumn 2015 Lecture 10 Minimum Spanning Trees
Lecture 32 CSE 331 Nov 14, 2011.
Lecture 29 CSE 331 Nov 8, 2017.
Lecture 32 CSE 331 Nov 15, 2017.
Lecture 33 CSE 331 Nov 14, 2014.
Lecture 30 CSE 331 Nov 10, 2017.
Lecture 27 CSE 331 Oct 31, 2014.
Lecture 25 CSE 331 Oct 28, 2013.
Lecture 25 CSE 331 Oct 27, 2014.
Lecture 28 CSE 331 Nov 7, 2012.
Lecture 27 CSE 331 Nov 2, 2010.
Lecture 31 CSE 331 Nov 12, 2010.
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
CSE 373: Data Structures and Algorithms
Lecture 36 CSE 331 Nov 28, 2011.
Lecture 36 CSE 331 Nov 30, 2012.
Autumn 2016 Lecture 10 Minimum Spanning Trees
Lecture 30 CSE 331 Nov 12, 2012.
CSE 417: Algorithms and Computational Complexity
Lecture 31 CSE 331 Nov 11, 2011.
Lecture 25 CSE 331 Oct 28, 2011.
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Winter 2019 Lecture 10 Minimum Spanning Trees
CSE 373: Data Structures and Algorithms
Lecture 14 Minimum Spanning Tree (cont’d)
CSE 332: Minimum Spanning Trees
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Lecture 27 CSE 331 Nov 4, 2016.
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Lecture 27 CSE 331 Nov 1, 2013.
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

Lecture 26 CSE 331 Nov 2, 2016

One-on-one meetings

Mini project video due ~1.5 weeks

Chunming’s address TODAY

Cut Property Lemma for MSTs Condition: S and V\S are non-empty V \ S S Cheapest crossing edge is in all MSTs Assumption: All edge costs are distinct

Optimality of Kruskal’s Algorithm V \ S S S Nodes connected to red in (V,T) Input: G=(V,E), ce> 0 for every e in E S is non-empty T = Ø V\S is non-empty Sort edges in increasing order of their cost First crossing edge considered Consider edges in sorted order If an edge can be added to T without adding a cycle then add it to T

Is (V,T) a spanning tree? No cycles by design G is disconnected! Just need to show that (V,T) is connected S’ V \ S’ No edges here

Removing distinct cost assumption Change all edge weights by very small amounts Make sure that all edge weights are distinct MST for “perturbed” weights is the same as for original Changes have to be small enough so that this holds EXERCISE: Figure out how to change costs

Running time for Prim’s algorithm Similar to Dijkstra’s algorithm O(m log n) Input: G=(V,E), ce> 0 for every e in E S = {s}, T = Ø While S is not the same as V Among edges e= (u,w) with u in S and w not in S, pick one with minimum cost Add w to S, e to T

Running time for Kruskal’s Algorithm Can be implemented in O(m log n) time (Union-find DS) Input: G=(V,E), ce> 0 for every e in E O(m2) time overall T = Ø Sort edges in increasing order of their cost Joseph B. Kruskal Consider edges in sorted order If an edge can be added to T without adding a cycle then add it to T Can be verified in O(m+n) time

Reading Assignment Sec 4.5, 4.6 of [KT]

High Level view of the course Problem Statement Problem Definition Three general techniques Done with greedy Algorithm “Implementation” Data Structures Analysis Correctness+Runtime Analysis

Trivia

Divide and Conquer Divide up the problem into at least two sub-problems Recursively solve the sub-problems “Patch up” the solutions to the sub-problems for the final solution

Sorting Given n numbers order them from smallest to largest Works for any set of elements on which there is a total order

Make sure that all the processed numbers are sorted Insertion Sort Make sure that all the processed numbers are sorted Input: a1, a2,…., an O(n2) overall Output: b1,b2,…,bn b1= a1 for i =2 … n Find 1 ≤ j ≤ i s.t. ai lies between bj-1 and bj Move bj to bi-1 one cell “down” bj=ai a b O(log n) 4 3 2 1 4 1 2 3 4 3 4 2 3 4 O(n)

Other O(n2) sorting algorithms Selection Sort: In every round pick the min among remaining numbers Bubble sort: The smallest number “bubbles” up

Divide and Conquer Divide up the problem into at least two sub-problems Recursively solve the sub-problems “Patch up” the solutions to the sub-problems for the final solution

Mergesort Algorithm Divide up the numbers in the middle Unless n=2 Sort each half recursively Merge the two sorted halves into one sorted output

How fast can sorted arrays be merged? Group talk time

Mergesort algorithm Input: a1, a2, …, an Output: Numbers in sorted order MergeSort( a, n ) If n = 2 return the order min(a1,a2); max(a1,a2) aL = a1,…, an/2 aR = an/2+1,…, an return MERGE ( MergeSort(aL, n/2), MergeSort(aR, n/2) ) If n = 1 return the order a1

An example run 1 51 100 19 2 8 3 4 51 1 19 100 2 8 4 3 1 19 51 100 2 3 4 8 1 2 3 4 8 19 51 100 MergeSort( a, n ) If n = 2 return the order min(a1,a2); max(a1,a2) aL = a1,…, an/2 aR = an/2+1,…, an return MERGE ( MergeSort(aL, n/2), MergeSort(aR, n/2) ) If n = 1 return the order a1

Inductive step follows from correctness of MERGE Input: a1, a2, …, an Output: Numbers in sorted order By induction on n MergeSort( a, n ) If n = 2 return the order min(a1,a2); max(a1,a2) aL = a1,…, an/2 aR = an/2+1,…, an return MERGE ( MergeSort(aL, n/2), MergeSort(aR, n/2) ) If n = 1 return the order a1 Inductive step follows from correctness of MERGE