! Break up problem into several parts. ! Solve each part recursively. ! Combine solutions to sub-problems into overall solution.

Size: px
Start display at page:

Download "! Break up problem into several parts. ! Solve each part recursively. ! Combine solutions to sub-problems into overall solution."

Transcription

1 Divide-and-Conquer Chapter 5 Divide and Conquer Divide-and-conquer.! Break up problem into several parts.! Solve each part recursively.! Combine solutions to sub-problems into overall solution. Most common usage.! Break up problem of size n into two equal parts of size!n.! Solve two parts recursively.! Combine two solutions into overall solution in linear time. Consequence.! Brute force: n 2. Slides by Kevin Wayne. Copyright 25 Pearson-Addison Wesley. All rights reserved.! Divide-and-conquer: n log n. Divide et impera. Veni, vidi, vici. - Julius Caesar 2 Sorting 5. Mergesort Sorting. Given n elements, rearrange in ascending order. Obvious sorting applications.! ist files in a directory.! Organize an MP3 library.! ist names in a phone book.! Display Google PageRank results. Non-obvious sorting applications.! Data compression.! Computer graphics.! Interval scheduling.! Computational biology.! Minimum spanning tree. Problems become easier once sorted.! Find the median.! Find the closest pair.! Binary search in a database.! Identify statistical outliers.! Supply chain management.! Simulate a system of particles.! Book recommendations on Amazon.! oad balancing on a parallel computer.! Find duplicates in a mailing list. 4

2 Mergesort Merging Mergesort.! Divide array into two halves.! Recursively sort each half.! Merge two halves to make sorted whole. Merging. Combine two pre-sorted lists into a sorted whole. How to merge efficiently?! inear number of comparisons.! Use temporary array. Jon von Neumann (945) A G O R I T H M S A G O R H I M S T A G O R I T H M S divide O() A G H I A G O R H I M S T sort 2T(n/2) A G H I M O R S T merge O(n) Challenge for the bored. In-place merge. [Kronrud, 969] using only a constant amount of extra storage 5 6 A Useful Recurrence Relation Proof by Recursion Tree Def. T(n) = number of comparisons to mergesort an input of size n. Mergesort recurrence. " if n = T(n) = # 2T(n /2) + n { otherwise sorting both halves merging T(n) " if n = ) ( T( # n/2 ) + T( n/2& ) { n otherwise ) * solve left half solve right half merging T(n) n T(n/2) T(n/2) 2(n/2) Solution. T(n) = O(n log 2 n). log 2 n 4(n/4) Assorted proofs. We describe several ways to prove this recurrence. Initially we assume n is a power of 2 and replace! with =. T(n / 2 k ) 2 k (n / 2 k ) T(2) T(2) T(2) T(2) T(2) T(2) T(2) T(2) n/2 (2) 7 n log 2 n 8

3 Proof by Telescoping Proof by Induction Claim. If T(n) satisfies this recurrence, then T(n) = n log 2 n. Claim. If T(n) satisfies this recurrence, then T(n) = n log 2 n. assumes n is a power of 2 assumes n is a power of 2 " if n = T(n) = # 2T(n/2) + n { otherwise sorting both halves merging " if n = T(n) = # 2T(n /2) + n { otherwise sorting both halves merging Pf. For n > : T(n) n = = = = 2T(n/2) n T(n /2) n/2 T(n / 4) n/4 T(n /n) n/n = log 2 n log 2 n Pf. (by induction on n)! Base case: n =.! Inductive hypothesis: T(n) = n log 2 n.! Goal: show that T(2n) = 2n log 2 (2n). T(2n) = 2T(n) + 2n = 2nlog 2 n + 2n = 2n( log 2 (2n) ") + 2n = 2nlog 2 (2n) 9 Analysis of Mergesort Recurrence Claim. If T(n) satisfies the following recurrence, then T(n)! n "lg n#. if n = log 2 n ) T(n) " ( T( # n /2 ) + T( n/2& ) + n { otherwise ) * solve left half solve right half merging 5.3 Counting Inversions Pf. (by induction on n)! Base case: n =.! Define n = n / 2, n 2 = "n / 2#.! Induction step: assume true for, 2,..., n. T(n) " T(n ) + T(n 2 ) + n " n # lgn + n 2 # lg n 2 + n " n # lgn 2 + n 2 # lg n 2 + n = n # lgn 2 + n " n( # lgn ) + n = n# lgn n 2 = " n/2# " # 2 " lg n # / 2 = 2 " lg n # / 2 lgn 2 " lg n# &

4 Counting Inversions Applications Music site tries to match your song preferences with others.! You rank n songs.! Music site consults database to find people with similar tastes. Similarity metric: number of inversions between two rankings.! My rank:, 2,, n.! Your rank: a, a 2,, a n.! Songs i and j inverted if i < j, but a i > a j. Applications.! Voting theory.! Collaborative filtering.! Measuring the "sortedness" of an array.! Sensitivity analysis of Googles ranking function.! Rank aggregation for meta-searching on the Web.! Nonparametric statistics (e.g., Kendalls Tau distance). Me You Songs A B C D E Inversions 3-2, 4-2 Brute force: check all &(n 2 ) pairs i and j. 3 4 Counting Inversions: Divide-and-Conquer Counting Inversions: Divide-and-Conquer Divide-and-conquer. Divide-and-conquer.! Divide: separate list into two pieces Divide: O()

5 Counting Inversions: Divide-and-Conquer Counting Inversions: Divide-and-Conquer Divide-and-conquer.! Divide: separate list into two pieces.! Conquer: recursively count inversions in each half. Divide-and-conquer.! Divide: separate list into two pieces.! Conquer: recursively count inversions in each half.! Combine: count inversions where a i and a j are in different halves, and return sum of three quantities Divide: O() Divide: O() Conquer: 2T(n / 2) Conquer: 2T(n / 2) 5 blue-blue inversions 8 green-green inversions 5 blue-blue inversions 8 green-green inversions 5-4, 5-2, 4-2, 8-2, , 9-3, 9-7, 2-3, 2-7, 2-, -3, -7 9 blue-green inversions 5-3, 4-3, 8-6, 8-3, 8-7, -6, -9, -3, -7 Combine:??? Total = = Counting Inversions: Combine Counting Inversions: Implementation Combine: count blue-green inversions! Assume each half is sorted.! Count inversions where a i and a j are in different halves.! Merge two sorted halves into sorted whole blue-green inversions: to maintain sorted invariant Count: O(n) Pre-condition. [Merge-and-Count] A and B are sorted. Post-condition. [Sort-and-Count] is sorted. Sort-and-Count() { if list has one element return and the list Divide the list into two halves A and B (r A, A) Sort-and-Count(A) (r B, B) Sort-and-Count(B) (r B, ) Merge-and-Count(A, B) Merge: O(n) } return r = r A + r B + r and the sorted list T(n) " T( # n/2 ) + T( n/2& ) + O(n) T(n) = O(nlog n) 9 2

6 Closest Pair of Points 5.4 Closest Pair of Points Closest pair. Given n points in the plane, find a pair with smallest Euclidean distance between them. Fundamental geometric primitive.! Graphics, computer vision, geographic information systems, molecular modeling, air traffic control.! Special case of nearest neighbor, Euclidean MST, Voronoi. fast closest pair inspired fast algorithms for these problems Brute force. Check all pairs of points p and q with &(n 2 ) comparisons. -D version. O(n log n) easy if points are on a line. Assumption. No two points have same x coordinate. to make presentation cleaner 22 Closest Pair of Points: First Attempt Closest Pair of Points: First Attempt Divide. Sub-divide region into 4 quadrants. Divide. Sub-divide region into 4 quadrants. Obstacle. Impossible to ensure n/4 points in each piece

7 Closest Pair of Points Closest Pair of Points Algorithm.! Divide: draw vertical line so that roughly!n points on each side. Algorithm.! Divide: draw vertical line so that roughly!n points on each side.! Conquer: find closest pair in each side recursively Closest Pair of Points Closest Pair of Points Algorithm.! Divide: draw vertical line so that roughly!n points on each side.! Conquer: find closest pair in each side recursively.! Combine: find closest pair with one point in each side.! Return best of 3 solutions. seems like &(n 2 ) Find closest pair with one point in each side, assuming that distance < ( ( = min(2, 2) 27 28

8 Closest Pair of Points Closest Pair of Points Find closest pair with one point in each side, assuming that distance < (.! Observation: only need to consider points within ( of line. Find closest pair with one point in each side, assuming that distance < (.! Observation: only need to consider points within ( of line.! Sort points in 2(-strip by their y coordinate ( = min(2, 2) 2 3 ( = min(2, 2) 2 ( 29 ( 3 Closest Pair of Points Closest Pair of Points Find closest pair with one point in each side, assuming that distance < (.! Observation: only need to consider points within ( of line. Def. et s i be the point in the 2(-strip, with the i th smallest y-coordinate.! Sort points in 2(-strip by their y coordinate.! Only check distances of those within positions in sorted list! Claim. If i j ) 2, then the distance between s i and s j is at least (. Pf j! No two points lie in same!(-by-!( box. 7 6! Two points at least 2 rows apart have distance ) 2(!().! 2 rows 29 3!(!( Fact. Still true if we replace 2 with 7. i 27 28!( 2 3 ( = min(2, 2) ( 3 ( ( 32

9 Closest Pair Algorithm Closest Pair of Points: Analysis Closest-Pair(p,, p n ) { Compute separation line such that half the points are on one side and half on the other side. ( = Closest-Pair(left half) ( 2 = Closest-Pair(right half) ( = min((, ( 2 ) Delete all points further than ( from separation line Sort remaining points by y-coordinate. Scan points in y-order and compare distance between each point and next neighbors. If any of these distances is less than (, update (. O(n log n) 2T(n / 2) O(n) O(n log n) O(n) Running time. T(n) " 2T( n/2) + O(n log n) # T(n) = O(n log 2 n) Q. Can we achieve O(n log n)? A. Yes. Dont sort points in strip from scratch each time.! Each recursive returns two lists: all points sorted by y coordinate, and all points sorted by x coordinate.! Sort by merging two pre-sorted lists. } return (. T(n) " 2T( n/2) + O(n) # T(n) = O(n log n) Integer Arithmetic 5.5 Integer Multiplication Add. Given two n-digit integers a and b, compute a + b.! O(n) bit operations. Multiply. Given two n-digit integers a and b, compute a " b.! Brute force solution: &(n 2 ) bit operations. * Multiply + Add 36

10 Divide-and-Conquer Multiplication: Warmup Karatsuba Multiplication To multiply two n-digit integers:! Multiply four!n-digit integers.! Add two!n-digit integers, and shift to obtain result. To multiply two n-digit integers:! Add two!n digit integers.! Multiply three!n-digit integers.! Add, subtract, and shift!n-digit integers to obtain result. x = 2 n /2 " x + x y = 2 n /2 " y + y ( ) ( 2 n /2 " y + y ) = 2 n " x y + 2 n /2 " x y + x y xy = 2 n /2 " x + x ( ) T(n) = 4T n / "(n) 23 # T(n) = "(n2 ) recursive calls add, shift assumes n is a power of 2 ( ) + x y x = 2 n /2 " x + x y = 2 n /2 " y + y xy = 2 n " x y + 2 n /2 " x y + x y ( ) + x y ( ) + x y = 2 n " x y + 2 n /2 " (x + x )(y + y ) # x y # x y A B A C C Theorem. [Karatsuba-Ofman, 962] Can multiply two n-digit integers in O(n.585 ) bit operations. ( ) + T( n/2 ) + T( + n /2 ) T(n) " T # n/2 & & + (n) recursive calls ( T(n) = O(n log 2 3 ) = O(n.585 ) add, subtract, shift Karatsuba: Recursion Tree " if n = T(n) = # 3T(n/2) + n otherwise log 2 n T(n) = " n 2 3 = k= ( ) k 3 2 ( ) +log 2 n # 3 2 # = 3n log2 3 # 2 Matrix Multiplication T(n) n T(n/2) T(n/2) T(n/2) 3(n/2) 9(n/4) T(n / 2 k ) 3 k (n / 2 k ) T(2) T(2) T(2) T(2) T(2) T(2) T(2) T(2) 3 lg n (2) 39

11 Matrix Multiplication Matrix Multiplication: Warmup Matrix multiplication. Given two n-by-n matrices A and B, compute C = AB. n c ij = " a ik b kj k= " c c 2 c n c 2 c 22 c 2n = M M O M # c n c n2 c nn & Brute force. &(n 3 ) arithmetic operations. " a a 2 a n a 2 a 22 a 2n ( M M O M # a n a n2 a nn & " b b b 2 n b 2 b 22 b 2n M M O M # b n b n2 b nn & Divide-and-conquer.! Divide: partition A and B into!n-by-!n blocks.! Conquer: multiply 8!n-by-!n recursively.! Combine: add appropriate products using 4 matrix additions. " C C 2 " = A A 2 " ( B B 2 # C 2 C 22 & # A 2 A 22 & # B 2 B 22 & ( ) + ( A 2 " B 2 ) ( ) + ( A 2 " B 22 ) ( ) + ( A 22 " B 2 ) ( ) + ( A 22 " B 22 ) C = A " B C 2 = A " B 2 C 2 = A 2 " B C 22 = A 2 " B 2 Fundamental question. Can we improve upon brute force? ( ) T(n) = 8T n/ "(n2 ) recursive calls add, form submatrices # T(n) = "(n 3 ) 4 42 Matrix Multiplication: Key Idea Fast Matrix Multiplication Key idea. multiply 2-by-2 block matrices with only 7 multiplications. " C C 2 " A = A 2 " ( B B 2 P = A " (B 2 # B 22 ) # C 2 C 22 & # A 2 A 22 & # B 2 B 22 & P 2 = ( A + A 2 ) " B 22 Fast matrix multiplication. (Strassen, 969)! Divide: partition A and B into!n-by-!n blocks.! Compute: 4!n-by-!n matrices via matrix additions.! Conquer: multiply 7!n-by-!n matrices recursively.! Combine: 7 products into 4 terms using 8 matrix additions. C = P 5 + P 4 " P 2 + P 6 C 2 = P + P 2 C 2 = P 3 + P 4 C 22 = P 5 + P " P 3 " P 7! 7 multiplications.! 8 = + 8 additions (or subtractions). P 3 = ( A 2 + A 22 ) " B P 4 = A 22 " (B 2 # B ) P 5 = ( A + A 22 ) " (B + B 22 ) P 6 = ( A 2 # A 22 ) " (B 2 + B 22 ) P 7 = ( A # A 2 ) " (B + B 2 ) Analysis.! Assume n is a power of 2.! T(n) = # arithmetic operations. ( ) T(n) = 7T n/ "(n2 ) # T(n) = "(n log 2 7 ) = O(n 2.8 ) recursive calls add, subtract 43 44

12 Fast Matrix Multiplication in Practice Fast Matrix Multiplication in Theory Implementation issues.! Sparsity.! Caching effects.! Numerical stability.! Odd matrix dimensions.! Crossover to classical algorithm around n = 28. Common misperception: "Strassen is only a theoretical curiosity."! Advanced Computation Group at Apple Computer reports 8x speedup on G4 Velocity Engine when n ~ 2,5.! Range of instances where its useful is a subject of controversy. Remark. Can "Strassenize" Ax=b, determinant, eigenvalues, and other matrix ops. Q. Multiply two 2-by-2 matrices with only 7 scalar multiplications? A. Yes! [Strassen, 969] "(n log 2 7 ) = O(n 2.8 ) Q. Multiply two 2-by-2 matrices with only 6 scalar multiplications? A. Impossible. [Hopcroft and Kerr, 97] "(n log 2 6 ) = O(n 2.59 ) Q. Two 3-by-3 matrices with only 2 scalar multiplications? A. Also impossible. "(n log 3 2 ) = O(n 2.77 ) Q. Two 7-by-7 matrices with only 43,64 scalar multiplications? A. Yes! [Pan, 98] "(n log ) = O(n 2.8 ) Decimal wars.! December, 979: O(n ).! January, 98: O(n ) Fast Matrix Multiplication in Theory Best known. O(n ) [Coppersmith-Winograd, 987.] Conjecture. O(n 2+* ) for any * >. Caveat. Theoretical improvements to Strassen are progressively less practical. 47

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 Divide-and-Conquer Chapter 5 Divide and Conquer Divide-and-conquer. Break up problem into several parts. Solve each part recursively. Combine solutions to sub-problems into overall solution. Most common

More information

Divide-and-Conquer. Consequence. Brute force: n 2. Divide-and-conquer: n log n. Divide et impera. Veni, vidi, vici.

Divide-and-Conquer. Consequence. Brute force: n 2. Divide-and-conquer: n log n. Divide et impera. Veni, vidi, vici. Divide-and-Conquer Divide-and-conquer. Break up problem into several parts. Solve each part recursively. Combine solutions to sub-problems into overall solution. Most common usage. Break up problem of

More information

Chapter 5. Divide and Conquer. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 5. Divide and Conquer. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 5 Divide and Conquer Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Divide-and-Conquer Divide-and-conquer. Break up problem into several parts. Solve each

More information

Chapter 5. Divide and Conquer CLRS 4.3. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 5. Divide and Conquer CLRS 4.3. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 5 Divide and Conquer CLRS 4.3 Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Divide-and-Conquer Divide-and-conquer. Break up problem into several parts. Solve

More information

Chapter 5. Divide and Conquer CLRS 4.3. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 5. Divide and Conquer CLRS 4.3. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 5 Divide and Conquer CLRS 4.3 Slides by Kevin Wayne. Copyright 25 Pearson-Addison Wesley. All rights reserved. Divide-and-Conquer Divide-and-conquer. Break up problem into several parts. Solve

More information

5. DIVIDE AND CONQUER I

5. DIVIDE AND CONQUER I 5. DIVIDE AND CONQUER I mergesort counting inversions closest pair of points median and selection Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

5. DIVIDE AND CONQUER I

5. DIVIDE AND CONQUER I 5. DIVIDE AND CONQUER I mergesort counting inversions closest pair of points randomized quicksort median and selection Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

Matrix Multiplication

Matrix Multiplication Matrix Multiplication Matrix Multiplication Matrix multiplication. Given two n-by-n matrices A and B, compute C = AB. n c ij = a ik b kj k=1 c 11 c 12 c 1n c 21 c 22 c 2n c n1 c n2 c nn = a 11 a 12 a 1n

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 9 Divide and Conquer Merge sort Counting Inversions Binary Search Exponentiation Solving Recurrences Recursion Tree Method Master Theorem Sofya Raskhodnikova S. Raskhodnikova;

More information

Divide-Conquer-Glue Algorithms

Divide-Conquer-Glue Algorithms Divide-Conquer-Glue Algorithms Mergesort and Counting Inversions Tyler Moore CSE 3353, SMU, Dallas, TX Lecture 10 Divide-and-conquer. Divide up problem into several subproblems. Solve each subproblem recursively.

More information

Chapter 5. Divide and Conquer. CS 350 Winter 2018

Chapter 5. Divide and Conquer. CS 350 Winter 2018 Chapter 5 Divide and Conquer CS 350 Winter 2018 1 Divide-and-Conquer Divide-and-conquer. Break up problem into several parts. Solve each part recursively. Combine solutions to sub-problems into overall

More information

CSE 421 Algorithms: Divide and Conquer

CSE 421 Algorithms: Divide and Conquer CSE 42 Algorithms: Divide and Conquer Larry Ruzzo Thanks to Richard Anderson, Paul Beame, Kevin Wayne for some slides Outline: General Idea algorithm design paradigms: divide and conquer Review of Merge

More information

How to Multiply. 5.5 Integer Multiplication. Complex Multiplication. Integer Arithmetic. Complex multiplication. (a + bi) (c + di) = x + yi.

How to Multiply. 5.5 Integer Multiplication. Complex Multiplication. Integer Arithmetic. Complex multiplication. (a + bi) (c + di) = x + yi. How to ultiply Slides by Kevin Wayne. Copyright 5 Pearson-Addison Wesley. All rights reserved. integers, matrices, and polynomials Complex ultiplication Complex multiplication. a + bi) c + di) = x + yi.

More information

5. DIVIDE AND CONQUER I

5. DIVIDE AND CONQUER I 5. DIVIDE AND CONQUER I mergesort counting inversions randomized quicksort median and selection closest pair of points Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

Divide-and-conquer. Curs 2015

Divide-and-conquer. Curs 2015 Divide-and-conquer Curs 2015 The divide-and-conquer strategy. 1. Break the problem into smaller subproblems, 2. recursively solve each problem, 3. appropriately combine their answers. Known Examples: Binary

More information

Divide-and-conquer: Order Statistics. Curs: Fall 2017

Divide-and-conquer: Order Statistics. Curs: Fall 2017 Divide-and-conquer: Order Statistics Curs: Fall 2017 The divide-and-conquer strategy. 1. Break the problem into smaller subproblems, 2. recursively solve each problem, 3. appropriately combine their answers.

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 //8 Fast Integer Division Too (!) Schönhage Strassen algorithm CS 8: Algorithm Design and Analysis Integer division. Given two n-bit (or less) integers s and t, compute quotient q = s / t and remainder

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 208 Announcement: Homework 3 due February 5 th at :59PM Final Exam (Tentative): Thursday, May 3 @ 8AM (PHYS 203) Recap: Divide

More information

Divide and Conquer. Recurrence Relations

Divide and Conquer. Recurrence Relations Divide and Conquer Recurrence Relations Divide-and-Conquer Strategy: Break up problem into parts. Solve each part recursively. Combine solutions to sub-problems into overall solution. 2 MergeSort Mergesort.

More information

CPS 616 DIVIDE-AND-CONQUER 6-1

CPS 616 DIVIDE-AND-CONQUER 6-1 CPS 616 DIVIDE-AND-CONQUER 6-1 DIVIDE-AND-CONQUER Approach 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances recursively 3. Obtain solution to original (larger)

More information

DIVIDE AND CONQUER II

DIVIDE AND CONQUER II DIVIDE AND CONQUER II master theorem integer multiplication matrix multiplication convolution and FFT Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

Divide and Conquer. Andreas Klappenecker. [based on slides by Prof. Welch]

Divide and Conquer. Andreas Klappenecker. [based on slides by Prof. Welch] Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch] Divide and Conquer Paradigm An important general technique for designing algorithms: divide problem into subproblems recursively

More information

1. Basic Algorithms: Bubble Sort

1. Basic Algorithms: Bubble Sort Sorting Algorithms Sorting Sorting. Given n elements, rearrange in ascending order. Obvious sorting applications. List files in a directory. Organize an MP3 library. List names in a phone book. Display

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 4: Divide and Conquer (I) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Divide and Conquer ( DQ ) First paradigm or framework DQ(S)

More information

1. Basic Algorithms: Bubble Sort

1. Basic Algorithms: Bubble Sort Sorting Algorithms Sorting Sorting. Given n elements, rearrange in ascending order. Obvious sorting applications. List files in a directory. Organize an MP3 library. List names in a phone book. Display

More information

Linear Time Selection

Linear Time Selection Linear Time Selection Given (x,y coordinates of N houses, where should you build road These lecture slides are adapted from CLRS.. Princeton University COS Theory of Algorithms Spring 0 Kevin Wayne Given

More information

CMPSCI611: Three Divide-and-Conquer Examples Lecture 2

CMPSCI611: Three Divide-and-Conquer Examples Lecture 2 CMPSCI611: Three Divide-and-Conquer Examples Lecture 2 Last lecture we presented and analyzed Mergesort, a simple divide-and-conquer algorithm. We then stated and proved the Master Theorem, which gives

More information

The Divide-and-Conquer Design Paradigm

The Divide-and-Conquer Design Paradigm CS473- Algorithms I Lecture 4 The Divide-and-Conquer Design Paradigm CS473 Lecture 4 1 The Divide-and-Conquer Design Paradigm 1. Divide the problem (instance) into subproblems. 2. Conquer the subproblems

More information

Algorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count

Algorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count Types of formulas for basic operation count Exact formula e.g., C(n) = n(n-1)/2 Algorithms, Design and Analysis Big-Oh analysis, Brute Force, Divide and conquer intro Formula indicating order of growth

More information

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem CS 577 Introduction to Algorithms: Jin-Yi Cai University of Wisconsin Madison In the last class, we described InsertionSort and showed that its worst-case running time is Θ(n 2 ). Check Figure 2.2 for

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Chapter 2 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: Room 5326, Engineering Building, Thursday 4:30pm -

More information

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

Lecture 1: Asymptotics, Recurrences, Elementary Sorting Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright Pearson-Addison Wesley. All rights reserved. 4 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and finishes

More information

Divide and Conquer Algorithms

Divide and Conquer Algorithms Divide and Conquer Algorithms T. M. Murali March 17, 2014 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine solutions

More information

CSC373: Algorithm Design, Analysis and Complexity Fall 2017

CSC373: Algorithm Design, Analysis and Complexity Fall 2017 CSC373: Algorithm Design, Analysis and Complexity Fall 2017 Allan Borodin (in collaboration with Rabia Bakhteri and with occasional guest lectures by Nisarg Shah and Denis Pankratov) September 13, 2017

More information

Introduction to Algorithms 6.046J/18.401J/SMA5503

Introduction to Algorithms 6.046J/18.401J/SMA5503 Introduction to Algorithms 6.046J/8.40J/SMA5503 Lecture 3 Prof. Piotr Indyk The divide-and-conquer design paradigm. Divide the problem (instance) into subproblems. 2. Conquer the subproblems by solving

More information

CSE 421 Algorithms. T(n) = at(n/b) + n c. Closest Pair Problem. Divide and Conquer Algorithms. What you really need to know about recurrences

CSE 421 Algorithms. T(n) = at(n/b) + n c. Closest Pair Problem. Divide and Conquer Algorithms. What you really need to know about recurrences CSE 421 Algorithms Richard Anderson Lecture 13 Divide and Conquer What you really need to know about recurrences Work per level changes geometrically with the level Geometrically increasing (x > 1) The

More information

Divide and Conquer Algorithms

Divide and Conquer Algorithms Divide and Conquer Algorithms Introduction There exist many problems that can be solved using a divide-and-conquer algorithm. A divide-andconquer algorithm A follows these general guidelines. Divide Algorithm

More information

Objec&ves. Review. Divide and conquer algorithms

Objec&ves. Review. Divide and conquer algorithms Objec&ves Divide and conquer algorithms Ø Recurrence rela&ons Ø Coun&ng inversions March 9, 2018 CSCI211 - Sprenkle 1 Review What approach are we learning to solve problems (as of Wednesday)? What is a

More information

Matching Residents to Hospitals

Matching Residents to Hospitals Midterm Review Matching Residents to Hospitals Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. Unstable pair: applicant x and

More information

Divide and conquer. Philip II of Macedon

Divide and conquer. Philip II of Macedon Divide and conquer Philip II of Macedon Divide and conquer 1) Divide your problem into subproblems 2) Solve the subproblems recursively, that is, run the same algorithm on the subproblems (when the subproblems

More information

Divide and Conquer Algorithms

Divide and Conquer Algorithms Divide and Conquer Algorithms T. M. Murali February 19, 2013 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine

More information

Kartsuba s Algorithm and Linear Time Selection

Kartsuba s Algorithm and Linear Time Selection CS 374: Algorithms & Models of Computation, Fall 2015 Kartsuba s Algorithm and Linear Time Selection Lecture 09 September 22, 2015 Chandra & Manoj (UIUC) CS374 1 Fall 2015 1 / 32 Part I Fast Multiplication

More information

A design paradigm. Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/ EECS 3101

A design paradigm. Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/ EECS 3101 A design paradigm Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/17 112 Multiplying complex numbers (from Jeff Edmonds slides) INPUT: Two pairs of integers, (a,b),

More information

Divide & Conquer. CS 320, Fall Dr. Geri Georg, Instructor CS320 Div&Conq 1

Divide & Conquer. CS 320, Fall Dr. Geri Georg, Instructor CS320 Div&Conq 1 Divide & Conquer CS 320, Fall 2017 Dr. Geri Georg, Instructor georg@colostate.edu CS320 Div&Conq 1 Strategy 1. Divide the problem up into equal sized sub problems 2. Solve the sub problems recursively

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 Algorithm runtime analysis and computational tractability Time Complexity of an Algorithm How do we measure the complexity (time, space requirements) of an algorithm. 1 microsecond? Units of time As soon

More information

Chapter 5 Divide and Conquer

Chapter 5 Divide and Conquer CMPT 705: Design and Analysis of Algorithms Spring 008 Chapter 5 Divide and Conquer Lecturer: Binay Bhattacharya Scribe: Chris Nell 5.1 Introduction Given a problem P with input size n, P (n), we define

More information

University of the Virgin Islands, St. Thomas January 14, 2015 Algorithms and Programming for High Schoolers. Lecture 5

University of the Virgin Islands, St. Thomas January 14, 2015 Algorithms and Programming for High Schoolers. Lecture 5 University of the Virgin Islands, St. Thomas January 14, 2015 Algorithms and Programming for High Schoolers Numerical algorithms: Lecture 5 Today we ll cover algorithms for various numerical problems:

More information

Reductions, Recursion and Divide and Conquer

Reductions, Recursion and Divide and Conquer Chapter 5 Reductions, Recursion and Divide and Conquer CS 473: Fundamental Algorithms, Fall 2011 September 13, 2011 5.1 Reductions and Recursion 5.1.0.1 Reduction Reducing problem A to problem B: (A) Algorithm

More information

Class Note #14. In this class, we studied an algorithm for integer multiplication, which. 2 ) to θ(n

Class Note #14. In this class, we studied an algorithm for integer multiplication, which. 2 ) to θ(n Class Note #14 Date: 03/01/2006 [Overall Information] In this class, we studied an algorithm for integer multiplication, which improved the running time from θ(n 2 ) to θ(n 1.59 ). We then used some of

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and

More information

COMP 355 Advanced Algorithms

COMP 355 Advanced Algorithms COMP 355 Advanced Algorithms Algorithm Design Review: Mathematical Background 1 Polynomial Running Time Brute force. For many non-trivial problems, there is a natural brute force search algorithm that

More information

2.1 Computational Tractability. Chapter 2. Basics of Algorithm Analysis. Computational Tractability. Polynomial-Time

2.1 Computational Tractability. Chapter 2. Basics of Algorithm Analysis. Computational Tractability. Polynomial-Time Chapter 2 2.1 Computational Tractability Basics of Algorithm Analysis "For me, great algorithms are the poetry of computation. Just like verse, they can be terse, allusive, dense, and even mysterious.

More information

CMPS 2200 Fall Divide-and-Conquer. Carola Wenk. Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk

CMPS 2200 Fall Divide-and-Conquer. Carola Wenk. Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk CMPS 2200 Fall 2017 Divide-and-Conquer Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 1 The divide-and-conquer design paradigm 1. Divide the problem (instance)

More information

Asymptotic Analysis and Recurrences

Asymptotic Analysis and Recurrences Appendix A Asymptotic Analysis and Recurrences A.1 Overview We discuss the notion of asymptotic analysis and introduce O, Ω, Θ, and o notation. We then turn to the topic of recurrences, discussing several

More information

Chapter 4 Divide-and-Conquer

Chapter 4 Divide-and-Conquer Chapter 4 Divide-and-Conquer 1 About this lecture (1) Recall the divide-and-conquer paradigm, which we used for merge sort: Divide the problem into a number of subproblems that are smaller instances of

More information

Lecture 2: Divide and conquer and Dynamic programming

Lecture 2: Divide and conquer and Dynamic programming Chapter 2 Lecture 2: Divide and conquer and Dynamic programming 2.1 Divide and Conquer Idea: - divide the problem into subproblems in linear time - solve subproblems recursively - combine the results in

More information

CSE 202 Dynamic Programming II

CSE 202 Dynamic Programming II CSE 202 Dynamic Programming II Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Algorithmic Paradigms Greed. Build up a solution incrementally,

More information

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30,

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, Divide and Conquer CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Merging sorted lists: WHAT Given two sorted lists a 1 a 2 a 3 a k b 1 b 2 b 3 b

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Lecture 6-8 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments

More information

2. ALGORITHM ANALYSIS

2. ALGORITHM ANALYSIS 2. ALGORITHM ANALYSIS computational tractability asymptotic order of growth survey of common running times Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

Algorithms 6.5 REDUCTIONS. designing algorithms establishing lower bounds classifying problems intractability

Algorithms 6.5 REDUCTIONS. designing algorithms establishing lower bounds classifying problems intractability 6.5 REDUCTIONS Algorithms F O U R T H E D I T I O N designing algorithms establishing lower bounds classifying problems intractability R O B E R T S E D G E W I C K K E V I N W A Y N E Algorithms, 4 th

More information

COMP 355 Advanced Algorithms Algorithm Design Review: Mathematical Background

COMP 355 Advanced Algorithms Algorithm Design Review: Mathematical Background COMP 355 Advanced Algorithms Algorithm Design Review: Mathematical Background 1 Polynomial Time Brute force. For many non-trivial problems, there is a natural brute force search algorithm that checks every

More information

Divide & Conquer. Jordi Cortadella and Jordi Petit Department of Computer Science

Divide & Conquer. Jordi Cortadella and Jordi Petit Department of Computer Science Divide & Conquer Jordi Cortadella and Jordi Petit Department of Computer Science Divide-and-conquer algorithms Strategy: Divide the problem into smaller subproblems of the same type of problem Solve the

More information

Algorithms. Algorithms 2.2 MERGESORT. mergesort bottom-up mergesort sorting complexity divide-and-conquer ROBERT SEDGEWICK KEVIN WAYNE

Algorithms. Algorithms 2.2 MERGESORT. mergesort bottom-up mergesort sorting complexity divide-and-conquer ROBERT SEDGEWICK KEVIN WAYNE Algorithms ROBERT SEDGEWICK KEVIN WAYNE 2.2 MERGESORT Algorithms F O U R T H E D I T I O N mergesort bottom-up mergesort sorting complexity divide-and-conquer ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu

More information

COMP 382: Reasoning about algorithms

COMP 382: Reasoning about algorithms Fall 2014 Unit 4: Basics of complexity analysis Correctness and efficiency So far, we have talked about correctness and termination of algorithms What about efficiency? Running time of an algorithm For

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17 601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17 2.1 Notes Homework 1 will be released today, and is due a week from today by the beginning

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 5: Divide and Conquer (Part 2) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ A Lower Bound on Convex Hull Lecture 4 Task: sort the

More information

Divide and Conquer. Maximum/minimum. Median finding. CS125 Lecture 4 Fall 2016

Divide and Conquer. Maximum/minimum. Median finding. CS125 Lecture 4 Fall 2016 CS125 Lecture 4 Fall 2016 Divide and Conquer We have seen one general paradigm for finding algorithms: the greedy approach. We now consider another general paradigm, known as divide and conquer. We have

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 14 Divide and Conquer Fast Fourier Transform Sofya Raskhodnikova 10/7/2016 S. Raskhodnikova; based on slides by K. Wayne. 5.6 Convolution and FFT Fast Fourier Transform:

More information

The PRIMES 2014 problem set

The PRIMES 2014 problem set Dear PRIMES applicant! The PRIMES 24 problem set This is the PRIMES 24 problem set. Please send us your solutions as part of your PRIMES application by December, 24. For complete rules, see http://web.mit.edu/primes/apply.shtml

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 Chapter 2 2.1 Computational Tractability Basics of Algorithm Analysis "For me, great algorithms are the poetry of computation. Just like verse, they can be terse, allusive, dense, and even mysterious.

More information

Algorithms And Programming I. Lecture 5 Quicksort

Algorithms And Programming I. Lecture 5 Quicksort Algorithms And Programming I Lecture 5 Quicksort Quick Sort Partition set into two using randomly chosen pivot 88 31 25 52 14 98 62 30 23 79 14 31 2530 23 52 88 62 98 79 Quick Sort 14 31 2530 23 52 88

More information

Divide-and-Conquer. Reading: CLRS Sections 2.3, 4.1, 4.2, 4.3, 28.2, CSE 6331 Algorithms Steve Lai

Divide-and-Conquer. Reading: CLRS Sections 2.3, 4.1, 4.2, 4.3, 28.2, CSE 6331 Algorithms Steve Lai Divide-and-Conquer Reading: CLRS Sections 2.3, 4.1, 4.2, 4.3, 28.2, 33.4. CSE 6331 Algorithms Steve Lai Divide and Conquer Given an instance x of a prolem, the method works as follows: divide-and-conquer

More information

CS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication

CS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication CS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication Integer multiplication Say we have 5 baskets with 8 apples in each How do we determine how many apples we have? Count them all? That would take

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Reminder: Homework 1 due tonight at 11:59PM! Recap: Greedy Algorithms Interval Scheduling Goal: Maximize number of meeting

More information

Introduction to Algorithms

Introduction to Algorithms Lecture 1 Introduction to Algorithms 1.1 Overview The purpose of this lecture is to give a brief overview of the topic of Algorithms and the kind of thinking it involves: why we focus on the subjects that

More information

Divide and Conquer. Chapter Overview. 1.2 Divide and Conquer

Divide and Conquer. Chapter Overview. 1.2 Divide and Conquer Chapter 1 Divide and Conquer 1.1 Overview This chapter introduces Divide and Conquer, which is a technique for designing recursive algorithms that are (sometimes) asymptotically efficient. It also presents

More information

Divide-and-Conquer. a technique for designing algorithms

Divide-and-Conquer. a technique for designing algorithms Divide-and-Conquer a technique for designing algorithms decomposing instance to be solved into subinstances of the same problem solving each subinstance combining subsolutions to obtain the solution to

More information

1 Divide and Conquer (September 3)

1 Divide and Conquer (September 3) The control of a large force is the same principle as the control of a few men: it is merely a question of dividing up their numbers. Sun Zi, The Art of War (c. 400 C.E.), translated by Lionel Giles (1910)

More information

Data Structures and Algorithms Chapter 3

Data Structures and Algorithms Chapter 3 1 Data Structures and Algorithms Chapter 3 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples

More information

Discrete Mathematics U. Waterloo ECE 103, Spring 2010 Ashwin Nayak May 17, 2010 Recursion

Discrete Mathematics U. Waterloo ECE 103, Spring 2010 Ashwin Nayak May 17, 2010 Recursion Discrete Mathematics U. Waterloo ECE 103, Spring 2010 Ashwin Nayak May 17, 2010 Recursion During the past week, we learnt about inductive reasoning, in which we broke down a problem of size n, into one

More information

Divide and Conquer Strategy

Divide and Conquer Strategy Divide and Conquer Strategy Algorithm design is more an art, less so a science. There are a few useful strategies, but no guarantee to succeed. We will discuss: Divide and Conquer, Greedy, Dynamic Programming.

More information

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d CS161, Lecture 4 Median, Selection, and the Substitution Method Scribe: Albert Chen and Juliana Cook (2015), Sam Kim (2016), Gregory Valiant (2017) Date: January 23, 2017 1 Introduction Last lecture, we

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and

More information

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Xi Chen Columbia University We continue with two more asymptotic notation: o( ) and ω( ). Let f (n) and g(n) are functions that map

More information

Divide and Conquer. Andreas Klappenecker

Divide and Conquer. Andreas Klappenecker Divide and Conquer Andreas Klappenecker The Divide and Conquer Paradigm The divide and conquer paradigm is important general technique for designing algorithms. In general, it follows the steps: - divide

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 5 Divide and Conquer: Fast Fourier Transform Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms

More information

shelat divide&conquer closest points matrixmult median

shelat divide&conquer closest points matrixmult median L6feb 9 2016 shelat 4102 divide&conquer closest points matrixmult median 7.5 7.8 9.5 3.7 26.1 closest pair of points simple brute force approach takes 14 1 2 7 8 9 4 13 3 10 11 5 12 6 solve the large problem

More information

Algorithms and Data Structures Strassen s Algorithm. ADS (2017/18) Lecture 4 slide 1

Algorithms and Data Structures Strassen s Algorithm. ADS (2017/18) Lecture 4 slide 1 Algorithms and Data Structures Strassen s Algorithm ADS (2017/18) Lecture 4 slide 1 Tutorials Start in week (week 3) Tutorial allocations are linked from the course webpage http://www.inf.ed.ac.uk/teaching/courses/ads/

More information

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: October 11. In-Class Midterm. ( 7:05 PM 8:20 PM : 75 Minutes )

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: October 11. In-Class Midterm. ( 7:05 PM 8:20 PM : 75 Minutes ) CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: October 11 In-Class Midterm ( 7:05 PM 8:20 PM : 75 Minutes ) This exam will account for either 15% or 30% of your overall grade depending on your

More information

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of

More information

CSE 613: Parallel Programming. Lectures ( Analyzing Divide-and-Conquer Algorithms )

CSE 613: Parallel Programming. Lectures ( Analyzing Divide-and-Conquer Algorithms ) CSE 613: Parallel Programming Lectures 13 14 ( Analyzing Divide-and-Conquer Algorithms ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Spring 2015 A Useful Recurrence Consider the

More information

Chapter 2. Divide-and-conquer. 2.1 Strassen s algorithm

Chapter 2. Divide-and-conquer. 2.1 Strassen s algorithm Chapter 2 Divide-and-conquer This chapter revisits the divide-and-conquer paradigms and explains how to solve recurrences, in particular, with the use of the master theorem. We first illustrate the concept

More information

CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015

CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015 CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015 1 Introduction The divide-and-conquer strategy is a general paradigm for algorithm design. This strategy

More information

Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201

Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201 Divide and Conquer: Polynomial Multiplication Version of October 7, 2014 Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201 Outline Outline: Introduction The polynomial multiplication

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms Spring 2017-2018 Outline 1 Sorting Algorithms (contd.) Outline Sorting Algorithms (contd.) 1 Sorting Algorithms (contd.) Analysis of Quicksort Time to sort array of length

More information

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 Approximation Algorithms Q. Suppose I need to solve an NP-hard problem. What should

More information

Fall 2017 November 10, Written Homework 5

Fall 2017 November 10, Written Homework 5 CS1800 Discrete Structures Profs. Aslam, Gold, & Pavlu Fall 2017 November 10, 2017 Assigned: Mon Nov 13 2017 Due: Wed Nov 29 2017 Instructions: Written Homework 5 The assignment has to be uploaded to blackboard

More information

feb abhi shelat Matrix, FFT

feb abhi shelat Matrix, FFT L7 feb 11 2016 abhi shelat Matrix, FFT userid: = Using the standard method, how many multiplications does it take to multiply two NxN matrices? cos( /4) = cos( /2) = sin( /4) = sin( /2) = Mergesort Karatsuba

More information