Punya Biswas Lecture 15 Closest Pair, Multiplication

Slides:



Advertisements
Similar presentations
2/9/06CS 3343 Analysis of Algorithms1 Convex Hull  Given a set of pins on a pinboard  And a rubber band around them  How does the rubber band look when.
Advertisements

A simple example finding the maximum of a set S of n numbers.
Copyright © 2007 Pearson Addison-Wesley. All rights reserved. Problem Reduction Dr. M. Sakalli Marmara Unv, Levitin ’ s notes.
Algorithm Design Techniques: Divide and Conquer. Introduction Divide and conquer – algorithm makes at least two recursive calls Subproblems should not.
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.
Divide and Conquer. Recall Complexity Analysis – Comparison of algorithm – Big O Simplification From source code – Recursive.
Nattee Niparnan. Recall  Complexity Analysis  Comparison of Two Algos  Big O  Simplification  From source code  Recursive.
CS38 Introduction to Algorithms Lecture 7 April 22, 2014.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
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 4: Divide and Conquer III: Other Applications and Examples Shang-Hua Teng.
CSE 421 Algorithms Richard Anderson Lecture 13 Divide and Conquer.
Lecture 33 CSE 331 Nov 17, Online office hours Alex will host the office hours.
CSE 421 Algorithms Richard Anderson Lecture 11 Recurrences.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 12.
Divide-and-Conquer 7 2  9 4   2   4   7
5.6 Convolution and FFT. 2 Fast Fourier Transform: Applications Applications. n Optics, acoustics, quantum physics, telecommunications, control systems,
Divide and Conquer Applications Sanghyun Park Fall 2002 CSE, POSTECH.
Lecture 28 CSE 331 Nov 9, Mini project report due WED.
CSE 421 Algorithms Lecture 15 Closest Pair, Multiplication.
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
Young CS 331 D&A of Algo. Topic: Divide and Conquer1 Divide-and-Conquer General idea: Divide a problem into subprograms of the same kind; solve subprograms.
CSCI 256 Data Structures and Algorithm Analysis Lecture 10 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Chapter 2. Divide-and-conquer Algorithms
Introduction to Algorithms: Divide-n-Conquer Algorithms
Chapter 2 Divide-and-Conquer algorithms
Chapter 2 Divide-and-Conquer algorithms
Lecture 4 Divide-and-Conquer
Chapter 4 Divide-and-Conquer
Lecture 3: Divide-and-conquer
CSCE350 Algorithms and Data Structure
Richard Anderson Lecture 14 Divide and Conquer
CSCE 411 Design and Analysis of Algorithms
Unit-2 Divide and Conquer
Richard Anderson Lecture 13 Recurrences and Divide and Conquer
Lecture 30 CSE 331 Nov 11, 2016.
Divide-and-Conquer 7 2  9 4   2   4   7
Topic: Divide and Conquer
Richard Anderson Lecture 11 Recurrences
Lecture 27 CSE 331 Nov 3, 2017.
Richard Anderson Lecture 13 Divide and Conquer
Richard Anderson Lecture 11 Minimum Spanning Trees
Richard Anderson Lecture 12 Recurrences and Divide and Conquer
Richard Anderson Lecture 14 Inversions, Multiplication, FFT
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.
Divide-and-Conquer The most-well known algorithm design strategy:
Lecture 31 CSE 331 Nov 14, 2012.
Divide-and-Conquer 7 2  9 4   2   4   7
Divide and Conquer Neil Tang 4/24/2008
Lecture 30 CSE 331 Nov 12, 2012.
CSCI 256 Data Structures and Algorithm Analysis Lecture 12
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.
Richard Anderson Lecture 14, Winter 2019 Divide and Conquer
Richard Anderson Lecture 14 Divide and Conquer
Divide-and-Conquer 7 2  9 4   2   4   7
Lecture 15 Closest Pair, Multiplication
Richard Anderson Lecture 12, Winter 2019 Recurrences
Lecture 27 CSE 331 Nov 4, 2016.
Given a list of n  8 integers, what is the runtime bound on the optimal algorithm that sorts the first eight? O(1) O(log n) O(n) O(n log n) O(n2)
Richard Anderson Lecture 12 Recurrences
Richard Anderson Lecture 13 Divide and Conquer
Presentation transcript:

Punya Biswas Lecture 15 Closest Pair, Multiplication CSE 421 Algorithms Punya Biswas Lecture 15 Closest Pair, Multiplication

Divide and Conquer Algorithms Mergesort, Quicksort Strassen’s Algorithm Inversion counting Closest Pair Algorithm (2d) Integer Multiplication (Karatsuba’s Algorithm) FFT Polynomial Multiplication Convolution

Closest Pair Problem Given a set of points find the pair of points p, q that minimizes dist(p, q)

Divide and conquer If we solve the problem on two subsets, does it help? (Separate by median x coordinate) d1 d2

Packing Lemma Suppose that the minimum distance between points is at least d, what is the maximum number of points that can be packed in a ball of radius d?

Combining Solutions Suppose the minimum separation from the sub problems is d In looking for cross set closest pairs, we only need to consider points with d of the boundary How many cross border interactions do we need to test?

A packing lemma bounds the number of distances to check

Details Preprocessing: sort points by y Merge step Select points in boundary zone For each point in the boundary Find highest point on the other side that is at most d above Find lowest point on the other side that is at most d below Compare with the points in this interval (there are at most 6)

Identify the pairs of points that are compared in the merge step following the recursive calls

Algorithm run time After preprocessing: T(n) = cn + 2 T(n/2)

Integer Arithmetic 9715480283945084383094856701043643845790217965702956767 + 1242431098234099057329075097179898430928779579277597977 Runtime for standard algorithm to add two n digit numbers: 2095067093034680994318596846868779409766717133476767930 X 5920175091777634709677679342929097012308956679993010921 Runtime for standard algorithm to multiply two n digit numbers:

Recursive Algorithm (First attempt) x = x1 2n/2 + x0 y = y1 2n/2 + y0 xy = (x1 2n/2 + x0) (y1 2n/2 + y0) = x1y1 2n + (x1y0 + x0y1)2n/2 + x0y0 Recurrence: Run time:

Simple algebra x = x1 2n/2 + x0 y = y1 2n/2 + y0 xy = x1y1 2n + (x1y0 + x0y1) 2n/2 + x0y0 p = (x1 + x0)(y1 + y0) = x1y1 + x1y0 + x0y1 + x0y0

Karatsuba’s Algorithm Multiply n-digit integers x and y Let x = x1 2n/2 + x0 and y = y1 2n/2 + y0 Recursively compute a = x1y1 b = x0y0 p = (x1 + x0)(y1 + y0) Return a2n + (p – a – b)2n/2 + b Recurrence: T(n) = 3T(n/2) + cn

FFT, Convolution and Polynomial Multiplication Preview FFT - O(n log n) algorithm Evaluate a polynomial of degree n at n points in O(n log n) time Computation of Convolution and Polynomial Multiplication (in O(n log n)) time