CSE 421 Algorithms Richard Anderson Lecture 13 Recurrences, Part 2.

Slides:



Advertisements
Similar presentations
Identity and Inverse Matrices
Advertisements

Computational Geometry - Part II Mohammed Nadeem Ahmed Raghavendra Kyatham.
A simple example finding the maximum of a set S of n numbers.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 4 Instructor: Paul Beame TA: Gidon Shavit.
Strassen's Matrix Multiplication Sibel KIRMIZIGÜL.
Divide-and-Conquer Matrix multiplication and Strassen’s algorithm Median Problem –In general finding the kth largest element of an unsorted list of numbers.
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.
1 Divide-and-Conquer CSC401 – Analysis of Algorithms Lecture Notes 11 Divide-and-Conquer Objectives: Introduce the Divide-and-conquer paradigm Review the.
Introduction to Algorithms 6.046J/18.401J L ECTURE 3 Divide and Conquer Binary search Powering a number Fibonacci numbers Matrix multiplication Strassen’s.
Lecture 2: Divide and Conquer algorithms Phan Thị Hà Dương
Recursion & Merge Sort Introduction to Algorithms Recursion & Merge Sort CSE 680 Prof. Roger Crawfis.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
CSE 421 Algorithms Richard Anderson Lecture 12 Recurrences.
Divide-and-Conquer Matrix multiplication and Strassen’s algorithm.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
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.
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.
4.7 Identity and Inverse Matrices. What is an identity? In math the identity is the number you multiply by to have equivalent numbers. For multiplication.
Divide-and-Conquer 7 2  9 4   2   4   7
MA/CSSE 473 Day 17 Divide-and-conquer Convex Hull Strassen's Algorithm: Matrix Multiplication.
Divide-and-Conquer Dr. B C Dhara Department of Information Technology Jadavpur University.
Data Structures and Algorithms A. G. Malamos
Project 2 due … Project 2 due … Project 2 Project 2.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
CSE 421 Algorithms Lecture 15 Closest Pair, Multiplication.
8.2 Operations With Matrices
ADA: 4.5. Matrix Mult.1 Objective o an extra divide and conquer example, based on a question in class Algorithm Design and Analysis (ADA) ,
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
Divide and Conquer. Recall Divide the problem into a number of sub-problems that are smaller instances of the same problem. Conquer the sub-problems by.
CSEP 521 Applied Algorithms Richard Anderson Winter 2013 Lecture 4.
What is Matrix Multiplication? Matrix multiplication is the process of multiplying two matrices together to get another matrix. It differs from scalar.
Divide and Conquer (Part II) Multiplication of two numbers Let U = (u 2n-1 u 2n-2 … u 1 u 0 ) 2 and V = (v 2n-1 v 2n-2 …v 1 v 0 ) 2, and our goal is to.
1 Complete this to a Pfaffian orientation (all internal faces have an odd number of clockwise arcs).
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
Equal costs at all levels
Introduction to Algorithms: Divide-n-Conquer Algorithms
Introduction to Algorithms: Recurrences
Divide-and-Conquer 6/30/2018 9:16 AM
Matrix Multiplication
Richard Anderson Lecture 14 Divide and Conquer
Punya Biswas Lecture 15 Closest Pair, Multiplication
Richard Anderson Lecture 13 Recurrences and Divide and Conquer
Divide-and-Conquer 7 2  9 4   2   4   7
Richard Anderson Lecture 11 Recurrences
Richard Anderson Lecture 13 Divide and Conquer
Richard Anderson Lecture 11 Minimum Spanning Trees
4.1 Matrices – Basic Operations
Richard Anderson Lecture 12 Recurrences and Divide and Conquer
Richard Anderson Lecture 14 Inversions, Multiplication, FFT
Richard Anderson Lecture 13 Recurrences, Part 2
Introduction to Algorithms
Divide-and-Conquer 7 2  9 4   2   4   7
Lecture 30 CSE 331 Nov 12, 2012.
Lecture 15, Winter 2019 Closest Pair, Multiplication
3.6 Multiply Matrices.
Richard Anderson Lecture 14 Divide and Conquer
Richard Anderson Lecture 13, Winter 2019 Recurrences, Part 2
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
Algorithms CSCI 235, Spring 2019 Lecture 8 Recurrences III
Richard Anderson Lecture 12 Recurrences
Richard Anderson Lecture 13 Divide and Conquer
Use of Submatrices If the original matrix is n x n, the four submatrices are n/2 x n/2 each; for simplicity we assume powers of two To find the result.
Presentation transcript:

CSE 421 Algorithms Richard Anderson Lecture 13 Recurrences, Part 2

Announcements Midterm – Monday, Nov 2, in class, closed book –Through section 5.2 –Midterm review Friday, 3:30-5:30 CSE 403 Homework 5 available

Recurrence Examples T(n) = 2 T(n/2) + cn –O(n log n) T(n) = T(n/2) + cn –O(n) More useful facts: –log k n = log 2 n / log 2 k –k log n = n log k

Unrolling the recurrence

Recursive Matrix Multiplication Multiply 2 x 2 Matrices: | r s | | a b| |e g| | t u| | c d| | f h| r = ae + bf s = ag + bh t = ce + df u = cg + dh A N x N matrix can be viewed as a 2 x 2 matrix with entries that are (N/2) x (N/2) matrices. The recursive matrix multiplication algorithm recursively multiplies the (N/2) x (N/2) matrices and combines them using the equations for multiplying 2 x 2 matrices =

Recursive Matrix Multiplication How many recursive calls are made at each level? How much work in combining the results? What is the recurrence?

What is the run time for the recursive Matrix Multiplication Algorithm? Recurrence:

T(n) = 4T(n/2) + cn

T(n) = 2T(n/2) + n 2

T(n) = 2T(n/2) + n 1/2

Recurrences Three basic behaviors –Dominated by initial case –Dominated by base case –All cases equal – we care about the depth

What you really need to know about recurrences Work per level changes geometrically with the level Geometrically increasing (x > 1) –The bottom level wins Geometrically decreasing (x < 1) –The top level wins Balanced (x = 1) –Equal contribution

Classify the following recurrences (Increasing, Decreasing, Balanced) T(n) = n + 5T(n/8) T(n) = n + 9T(n/8) T(n) = n 2 + 4T(n/2) T(n) = n 3 + 7T(n/2) T(n) = n 1/2 + 3T(n/4)

Strassen’s Algorithm Multiply 2 x 2 Matrices: | r s | | a b| |e g| | t u| | c d| | f h| r = p 1 + p 4 – p 5 + p 7 s = p 3 + p 5 t = p 2 + p 5 u = p 1 + p 3 – p 2 + p 7 Where: p 1 = (b + d)(f + g) p 2 = (c + d)e p 3 = a(g – h) p 4 = d(f – e) p 5 = (a – b)h p 6 = (c – d)(e + g) p 7 = (b – d)(f + h) =

Recurrence for Strassen’s Algorithms T(n) = 7 T(n/2) + cn 2 What is the runtime?

BFPRT Recurrence T(n) <= T(3n/4) + T(n/5) + 20 n What bound do you expect?