Lecture 32 CSE 331 Nov 18, 2009. HW 8 solutions Friday.

Slides:



Advertisements
Similar presentations
1 Divide & Conquer Algorithms. 2 Recursion Review A function that calls itself either directly or indirectly through another function Recursive solutions.
Advertisements

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.
CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
CS38 Introduction to Algorithms Lecture 7 April 22, 2014.
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 38 CSE 331 Dec 7, The last few days Today: Solutions to HW 9 (end of lecture) Wednesday: Graded HW 9 (?), Sample final, Blog post on the.
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 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 34 CSE 331 Nov 30, Graded HW 8 On Wednesday.
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 37 CSE 331 Dec 1, A new grading proposal Towards your final score in the course MAX ( mid-term as 25%+ finals as 40%, finals as 65%) .
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.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
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.
Foundations II: Data Structures and Algorithms
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
1 Algorithms CSCI 235, Fall 2015 Lecture 7 Recurrences II.
CSE 331: Review.
1 Overview Divide and Conquer Merge Sort Quick Sort.
CSE 331: Review August 1, Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical.
Lecture 2: Divide and Conquer
Unit 1. Sorting and Divide and Conquer
Lecture 31 CSE 331 Nov 14, 2016.
Lecture 4 Divide-and-Conquer
Lecture 31 CSE 331 Nov 13, 2017.
Lecture 34 CSE 331 Nov 26, 2012.
Richard Anderson Lecture 14 Divide and Conquer
Growth Functions Algorithms Lecture 8
Chapter 2: Getting Started
Punya Biswas Lecture 15 Closest Pair, Multiplication
Lecture 30 CSE 331 Nov 11, 2016.
Lecture 33 CSE 331 Nov 19, 2012.
Richard Anderson Lecture 11 Recurrences
Lecture 27 CSE 331 Nov 3, 2017.
Richard Anderson Lecture 13 Divide and Conquer
Lecture 32 CSE 331 Nov 14, 2011.
Lecture 29 CSE 331 Nov 8, 2017.
Lecture 28 CSE 331 Nov 7, 2016.
Lecture 30 CSE 331 Nov 10, 2017.
Lecture 33 CSE 331 Nov 15, 2013.
Lecture 27 CSE 331 Nov 2, 2010.
Lecture 31 CSE 331 Nov 14, 2012.
Lecture 31 CSE 331 Nov 12, 2010.
Trevor Brown CS 341: Algorithms Trevor Brown
Divide & Conquer Algorithms
Lecture 30 CSE 331 Nov 12, 2012.
Lecture 2: Divide and Conquer
Algorithms CSCI 235, Spring 2019 Lecture 7 Recurrences II
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 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 18, 2009

HW 8 solutions Friday

Counting Inversions Input: n distinct numbers a 1,a 2,…,a n Inversion: (i,j) with i a j Output: Number of inversions

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 Solve the stronger problem of counting inversions + sorting

Three kinds of inversion Non-crossing inversions are counted recursively

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

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