Lecture 28 CSE 331 Nov 9, 2009. 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.

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

1 Merge Sort Review of Sorting Merge Sort. 2 Sorting Algorithms Selection Sort uses a priority queue P implemented with an unsorted sequence: –Phase 1:
Lecture 30 CSE 331 Nov 8, HW 7 due today Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm DO NOT FORGET TO WRITE DOWN YOUR.
Lecture 30 CSE 331 Nov 13, To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM.
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 32 CSE 331 Nov 18, HW 8 solutions Friday.
Lecture 31 CSE 331 Nov 16, Jeff is out of town this week No regular recitation or Jeff’s normal office hours I’ll hold extra Question sessions Mon,
Lecture 38 CSE 331 Dec 3, A new grading proposal Towards your final score in the course MAX ( mid-term as 25%+ finals as 40%, finals as 65%) .
Lecture 34 CSE 331 Nov 30, Graded HW 8 On Wednesday.
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.
Lecture 33 CSE 331 Nov 17, Online office hours Alex will host the office hours.
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.
CSE 331: Review. Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical def “Implementation”
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)
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
CSE 340: Review (at last!) Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order.
CSC317 1 So far so good, but can we do better? Yes, cheaper by halves... orkbook/cheaperbyhalf.html.
Sorting Quick, Merge & Radix Divide-and-conquer Technique subproblem 2 of size n/2 subproblem 1 of size n/2 a solution to subproblem 1 a solution to.
CSCI 256 Data Structures and Algorithm Analysis Lecture 10 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Lecture 33 CSE 331 Nov 20, HW 8 due today Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm Submit your HWs to the side of.
CMPT 238 Data Structures More on Sorting: Merge Sort and Quicksort.
CSE 331: Review August 1, Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical.
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)
May 12th – Minimum Spanning Trees
Lecture 32 CSE 331 Nov 16, 2016.
Lecture 31 CSE 331 Nov 14, 2016.
Lecture 26 CSE 331 Nov 2, 2016.
Lecture 31 CSE 331 Nov 13, 2017.
Divide and Conquer / Closest Pair of Points Yin Tat Lee
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 33 CSE 331 Nov 17, 2017.
Lecture 26 CSE 331 Nov 1, 2017.
Lecture 27 CSE 331 Nov 3, 2017.
Lecture 26 CSE 331 Nov 2, 2012.
Lecture 29 CSE 331 Nov 8, 2017.
Divide and Conquer Algorithms Part I
Lecture 32 CSE 331 Nov 15, 2017.
Lecture 33 CSE 331 Nov 14, 2014.
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 14, 2012.
CSE 373: Data Structures and Algorithms
Lecture 36 CSE 331 Nov 30, 2012.
Lecture 30 CSE 331 Nov 12, 2012.
Divide & Conquer Sorting
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.
Lecture 19 CSE 331 Oct 10, 2016.
CSE 373: Data Structures and Algorithms
Lecture 14 Minimum Spanning Tree (cont’d)
Lecture 27 CSE 331 Nov 4, 2016.
Lecture 27 CSE 331 Nov 1, 2013.
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

Lecture 28 CSE 331 Nov 9, 2009

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 deadline to see if an alternative exists

Last Lecture Kruskal’s and Prim’s algorithms are optimal*

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 Input: G=(V,E), c e > 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 O(m log n)

Running time for Kruskal’s Algorithm Joseph B. Kruskal Input: G=(V,E), c e > 0 for every e in E T = Ø Sort edges in increasing order of their cost 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 O(m 2 ) time overall Can be implemented in O(m log n) time (Union-find DS)

Reading Assignment Sec 4.5, 4.6 of [KT]

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

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

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

Other O(n 2 ) 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 Sort each half recursively Merge the two sorted halves into one sorted output Unless n=2

How fast can sorted arrays be merged? Group talk time