Lecture 32 CSE 331 Nov 14, 2011.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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 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.
CSE 421 Algorithms Richard Anderson Lecture 12 Recurrences.
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 34 CSE 331 Nov 19, HW 9 due today Q1 in one pile and Q 2+3 in another I will not take any HW after 1:15pm.
Lecture 33 CSE 331 Nov 20, Homeworks Submit HW 9 by 1:10PM HW 8 solutions at the end of the lecture.
Lecture 32 CSE 331 Nov 15, Feedback Forms Link for the survey on the blog.
Lecture 34 CSE 331 Nov 23, Homework related stuff Graded HW 8+9, solutions to HW 9 the week after Thanksgiving.
Lecture 33 CSE 331 Nov 17, Online office hours Alex will host the office hours.
CSE 421 Algorithms Richard Anderson Lecture 11 Recurrences.
Lecture 30 CSE 331 Nov 10, Online Office Hours
Lecture 29 CSE 331 Nov 11, To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM.
Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.
Lecture 28 CSE 331 Nov 9, Mini project report due WED.
CSE 421 Algorithms Lecture 15 Closest Pair, Multiplication.
Lecture 2: Divide and Conquer
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.
Lecture 34 CSE 331 Nov 26, 2012.
Richard Anderson Lecture 14 Divide and Conquer
Lecture 34 CSE 331 Nov 26, 2012.
Punya Biswas Lecture 15 Closest Pair, Multiplication
Lecture 14 CSE 331 Sep 30, 2011.
Lecture 30 CSE 331 Nov 11, 2016.
Lecture 33 CSE 331 Nov 19, 2012.
Lecture 26 CSE 331 Nov 1, 2017.
Richard Anderson Lecture 11 Recurrences
Lecture 27 CSE 331 Nov 3, 2017.
Richard Anderson Lecture 13 Divide and Conquer
Richard Anderson Lecture 14 Inversions, Multiplication, FFT
Lecture 29 CSE 331 Nov 8, 2017.
Lecture 28 CSE 331 Nov 7, 2016.
Lecture 37 CSE 331 Nov 30, 2011.
Lecture 18 CSE 331 Oct 12, 2011.
Lecture 19 CSE 331 Oct 8, 2014.
Lecture 20 CSE 331 Oct 17, 2011.
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 33 CSE 331 Nov 15, 2013.
Lecture 34 CSE 331 Nov 18, 2011.
Lecture 28 CSE 331 Nov 7, 2012.
Lecture 27 CSE 331 Nov 2, 2010.
Lecture 18 CSE 331 Oct 9, 2017.
Lecture 31 CSE 331 Nov 14, 2012.
Lecture 31 CSE 331 Nov 12, 2010.
Lecture 10 CSE 331 Sep 21, 2012.
Lecture 36 CSE 331 Nov 28, 2011.
Lecture 36 CSE 331 Nov 30, 2012.
Lecture 30 CSE 331 Nov 12, 2012.
Lecture 40 CSE 331 Dec 7, 2011.
Lecture 15, Winter 2019 Closest Pair, Multiplication
Richard Anderson Lecture 14 Divide and Conquer
Lecture 31 CSE 331 Nov 11, 2011.
Lecture 30 CSE 331 Nov 9, 2011.
Lecture 19 CSE 331 Oct 10, 2016.
Lecture 32 CSE 331 Nov 12, 2014.
Richard Anderson Lecture 14, Winter 2019 Divide and Conquer
Richard Anderson Lecture 14 Divide and Conquer
Lecture 15 Closest Pair, Multiplication
Richard Anderson Lecture 12, Winter 2019 Recurrences
Lecture 27 CSE 331 Nov 4, 2016.
Richard Anderson Lecture 12 Recurrences
Richard Anderson Lecture 13 Divide and Conquer
Lecture 27 CSE 331 Nov 1, 2013.
Presentation transcript:

Lecture 32 CSE 331 Nov 14, 2011

HW related stuff HW 8 solutions at the end of the lecture HW 7 available for pickup

Review Sessions this week Tuesday, 1:00-1:50pm– Jesse Commons 9 (Review of covered material) Friday, 11:30am-12:20pm– Atri Bell 242 (problem solving session) For more details, check out for the blog post

Need a blog and scribe volunteer

Counting Inversions Input: n distinct numbers a1,a2,…,an Inversion: (i,j) with i < j s.t. ai > aj Output: Number of inversions

Solve the stronger problem of counting inversions + sorting Divide and Conquer Divide up the problem into at least two sub-problems Solve the stronger problem of counting inversions + sorting Recursively solve the sub-problems “Patch up” the solutions to the sub-problems for the final solution

Three kinds of inversion 10 7 21 20 100 1 Non-crossing inversions are counted recursively

Mergesort-Count algorithm Input: a1, a2, …, an Output: Numbers in sorted order+ #inversion T(2) = c T(n) = 2T(n/2) + cn MergeSortCount( a, n ) If n = 1 return ( 0 , a1) If n = 2 return ( a1 > a2, min(a1,a2); max(a1,a2)) O(n log n) time aL = a1,…, an/2 aR = an/2+1,…, an (cL, aL) = MergeSortCount(aL, n/2) (cR, aR) = MergeSortCount(aR, n/2) O(n) Counts #crossing-inversions+ MERGE (c, a) = MERGE-COUNT(aL,aR) return (c+cL+cR,a)

Today’s agenda MERGE-COUNT Computing closest pair of points

Closest pairs of points Input: n 2-D points P = {p1,…,pn}; pi=(xi,yi) d(pi,pj) = ( (xi-xj)2+(yi-yj)2)1/2 Output: Points p and q that are closest

Group Talk time O(n2) time algorithm? 1-D problem in time O(n log n) ?

Sorting to rescue in 2-D? Pick pairs of points closest in x co-ordinate Pick pairs of points closest in y co-ordinate Choose the better of the two

Rest of today’s agenda Divide and Conquer based algorithm