Divide-and-Conquer. Divide-and-Conquer 1

Similar documents
Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Divide-and-Conquer

Merge Sort. Outline and Reading. Divide-and-Conquer. Divide-and-conquer paradigm ( 4.1.1) Merge-sort ( 4.1.1)

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Divide-and-Conquer

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem

Data Structures Lecture 9

CSED233: Data Structures (2018F) Lecture13: Sorting and Selection

Improving The Problem Not the Code

5. Solving recurrences

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

Week 13 Notes: 1) Riemann Sum. Aim: Compute Area Under a Graph. Suppose we want to find out the area of a graph, like the one on the right:

Section IV.6: The Master Method and Applications

Merge and Quick Sort

Fundamental Algorithms

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Introduction to Algorithms 6.046J/18.401J

Algorithms and Data Structures Lecture IV

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication

Attempt any TEN of the following:

Model of Computation and Runtime Analysis

Data Structures and Algorithms

Physics 235 Final Examination December 4, 2006 Solutions

Divide and Conquer II

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

Algorithms Design & Analysis. Divide & Conquer

Numerical Integration - (4.3)

Review of the Riemann Integral

Data Structures and Algorithm. Xiaoqing Zheng

Model of Computation and Runtime Analysis

Design and Analysis of Algorithms

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

CSE 5311 Notes 1: Mathematical Preliminaries

Convergence of the FEM. by Hui Zhang Jorida Kushova Ruwen Jung

Chapter 7 Infinite Series

4.3 Growth Rates of Solutions to Recurrences

1.3 Continuous Functions and Riemann Sums

B. Examples 1. Finite Sums finite sums are an example of Riemann Sums in which each subinterval has the same length and the same x i

Chapter 5. The Riemann Integral. 5.1 The Riemann integral Partitions and lower and upper integrals. Note: 1.5 lectures

Function Composition and Chain Rules

Thomas J. Osler Mathematics Department Rowan University Glassboro NJ Introduction

1 + t5 dt with respect to x. du = 2. dg du = f(u). du dx. dg dx = dg. du du. dg du. dx = 4x3. - page 1 -

Limit of a function:

Continuity and Differentiability of the Trigonometric Functions

A GENERAL METHOD FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS: THE FROBENIUS (OR SERIES) METHOD

) 2 2(2. Assume that

Numbers (Part I) -- Solutions

Exponential Families and Friends: Learning the Parameters of the a Fully Observed BN. Kayhan Batmanghelich

Econ 401A Three extra questions John Riley. Homework 3 Due Tuesday, Nov 28

Taylor Polynomials. The Tangent Line. (a, f (a)) and has the same slope as the curve y = f (x) at that point. It is the best

Digital Signal Processing, Fall 2006

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro

Discrete Mathematics I Tutorial 12

Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:

Fundamental Theorem of Calculus

Multiplicative Versions of Infinitesimal Calculus

ALGEBRA. ( ) is a point on the line ( ) + ( ) = + ( ) + + ) + ( Distance Formula The distance d between two points x, y

Stepped-Impedance Low-Pass Filters

Math Week 5 concepts and homework, due Friday February 10


CIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.

CS473-Algorithms I. Lecture 3. Solving Recurrences. Cevdet Aykanat - Bilkent University Computer Engineering Department

Topic 4 Fourier Series. Today

We will begin by supplying the proof to (a).

COMP285 Midterm Exam Department of Mathematics

Convergence rates of approximate sums of Riemann integrals

Second Mean Value Theorem for Integrals By Ng Tze Beng. The Second Mean Value Theorem for Integrals (SMVT) Statement of the Theorem

SUTCLIFFE S NOTES: CALCULUS 2 SWOKOWSKI S CHAPTER 11

Appendix A Examples for Labs 1, 2, 3 1. FACTORING POLYNOMIALS

CS 5150/6150: Assignment 1 Due: Sep 23, 2010

Lecture 7: Solving Recurrences

f(t)dt 2δ f(x) f(t)dt 0 and b f(t)dt = 0 gives F (b) = 0. Since F is increasing, this means that

MATH 174: Numerical Analysis. Lecturer: Jomar F. Rabajante 1 st Sem AY

Math 31A Discussion Notes Week 4 October 20 and October 22, 2015

Section 2.1 The Definition of the Derivative. We are interested in finding the slope of the tangent line at a specific point.

Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone:

If a is any non zero real or imaginary number and m is the positive integer, then a...

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

Topic 9 - Taylor and MacLaurin Series

ORIE 633 Network Flows September 27, Lecture 8

Online Appendix for Lerner Symmetry: A Modern Treatment

ALLOCATING SAMPLE TO STRATA PROPORTIONAL TO AGGREGATE MEASURE OF SIZE WITH BOTH UPPER AND LOWER BOUNDS ON THE NUMBER OF UNITS IN EACH STRATUM

12 Basic Integration in R

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

We first write the integrand into partial fractions and then integrate. By EXAMPLE 27 we have the identity

Strauss PDEs 2e: Section Exercise 4 Page 1 of 5. u tt = c 2 u xx ru t for 0 < x < l u = 0 at both ends u(x, 0) = φ(x) u t (x, 0) = ψ(x),

Approximate Integration

Module 4. Signal Representation and Baseband Processing. Version 2 ECE IIT, Kharagpur

Lecture 16: Monotone Formula Lower Bounds via Graph Entropy. 2 Monotone Formula Lower Bounds via Graph Entropy

232 Calculus and Structures

CSE Introduction to Parallel Processing. Chapter 3. Parallel Algorithm Complexity

Simpson s 1/3 rd Rule of Integration

MAT 1275: Introduction to Mathematical Analysis

Function Composition and Chain Rules

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018

Maths for Computer Graphics

CS 332: Algorithms. Quicksort

Topic 6b Finite Difference Approximations

Transcription:

Divide-d-Coquer 7 9 4 4 7 9 7 7 9 4 4 9 7 7 9 9 4 4 Divide-d-Coquer 1

Outie d Redig Divide-d-coquer prdigm 5. Review Merge-sort 4.1.1 Recurrece Equtios 5..1 tertive sustitutio Recursio trees Guess-d-test Te mster metod teger Mutipictio 5.. Divide-d-Coquer

Divide-d-Coquer Divide-d coquer is geer goritm desig prdigm: Divide: divide te iput dt S i two or more disjoit susets S 1, S, Recur: sove te suproems recursivey Coquer: comie te soutios or S 1,S,, ito soutio or S Te se cse or te recursio re suproems o costt size Aysis c e doe usig recurrece equtios Divide-d-Coquer 3

Merge-Sort Review Merge-sort o iput sequece S wit eemets cosists o tree steps: Divide: prtitio S ito two sequeces S 1 d S o out eemets ec Recur: recursivey sort S 1 d S Coquer: merge S 1 d S ito uique sorted sequece Agoritm mergesorts, C put sequece S wit eemets, comprtor C Output sequece S sorted ccordig to C S.size > 1 S 1, S prtitios, mergesorts 1, C mergesorts, C S merges 1, S Divide-d-Coquer 4

Recurrece Equtio Aysis Te coquer step o merge-sort cosists o mergig two sorted sequeces, ec wit eemets d impemeted y mes o douy iked ist, tkes t most steps, or some costt. Likewise, te sis cse < wi tke t most steps. Tereore, we et T deote te ruig time o merge-sort: T T < We c tereore yze te ruig time o merge-sort y idig cosed orm soutio to te ove equtio. Tt is, soutio tt s T oy o te et-d side. Divide-d-Coquer 5

tertive Sustitutio te itertive sustitutio, or pug-d-cug, tecique, we itertivey ppy te recurrece equtio to itse d see we c id ptter: T T T T 3 3 T 3 4 4 T 4... i i T i Note tt se, T, cse occurs we i. Tt is, i. So, T Tus, T is O. Divide-d-Coquer 6

Te Recursio Tree Drw te recursio tree or te recurrece retio d ook or ptter: < T T dept 0 T s 1 size time 1 i i i Tot time st eve pus previous eves Divide-d-Coquer 7

Guess-d-Test Metod te guess-d-test metod, we guess cosed orm soutio d te try to prove it is true y iductio: < T T Guess: T < c. T T c c c c Wrog: we cot mke tis st ie e ess t c Divide-d-Coquer 8

Guess-d-Test Metod, Prt Rec te recurrece equtio: T T Guess #: T < c. T T c c c < c c c c >. So, T is O. geer, to use tis metod, you eed to ve good guess d you eed to e good t iductio proos. Divide-d-Coquer 9

Divide-d-Coquer 10 Mster Metod My divide-d-coquer recurrece equtios ve te orm: Te Mster Teorem: < d T d c T 1. or some provided, is te, is 3. is te, is. is te, is 1. 1 < Θ Ω Θ Θ Θ δ δ ε ε T T T O k k

Mster Metod, Exmpe 1 Te orm: Te Mster Teorem: 1.. 3. provided Exmpe: T is O c T is Θ is Ω ε ε δ, te T is Θ k or some δ < 1. < d d, te T is Θ, te T is Θ, T 4T k 1 Soutio:, so cse 1 sys T is O. Divide-d-Coquer 11

Mster Metod, Exmpe Te orm: Te Mster Teorem: 1.. 3. provided Exmpe: T is O c T is Θ is Ω ε ε δ, te T is Θ k or some δ < 1. < d d, te T is Θ, te T is Θ, T T k 1 Soutio: 1, so cse sys T is O. Divide-d-Coquer 1

Mster Metod, Exmpe 3 Te orm: Te Mster Teorem: 1.. 3. provided Exmpe: T is O c T is Θ is Ω ε ε δ, te T is Θ T T 3 k or some δ < 1. < d d, te T is Θ, te T is Θ, k 1 Soutio: 0, so cse 3 sys T is O. Divide-d-Coquer 13

Mster Metod, Exmpe 4 Te orm: Te Mster Teorem: 1.. 3. provided Exmpe: T is O c T is Θ is Ω ε ε δ, te T is Θ k or some δ < 1. < d d, te T is Θ, te T is Θ, T 8T Soutio: 3, so cse 1 sys T is O 3. k 1 Divide-d-Coquer 14

Mster Metod, Exmpe 5 Te orm: Te Mster Teorem: 1.. 3. provided Exmpe: T is O c T is Θ is Ω ε ε δ, te T is Θ k or some δ < 1. < d d, te T is Θ, te T is Θ, T 9T 3 3 Soutio:, so cse 3 sys T is O 3. k 1 Divide-d-Coquer 15

Mster Metod, Exmpe 6 Te orm: Te Mster Teorem: 1.. 3. provided Exmpe: T is O c T is Θ is Ω ε ε δ, te T is Θ k or some δ < 1. < d d, te T is Θ, te T is Θ, T T 1 k 1 iry serc Soutio: 0, so cse sys T is O. Divide-d-Coquer 16

Mster Metod, Exmpe 7 Te orm: Te Mster Teorem: 1.. 3. provided Exmpe: T is O c T is Θ is Ω ε ε δ, te T is Θ k or some δ < 1. < d d, te T is Θ, te T is Θ, T T k 1 ep costructio Soutio: 1, so cse 1 sys T is O. Divide-d-Coquer 17

Divide-d-Coquer 18 tertive Proo o te Mster Teorem Usig itertive sustitutio, et us see we c id ptter: We te distiguis te tree cses s Te irst term is domit Ec prt o te summtio is equy domit Te summtio is geometric series 1 0 1 0 3 3 1 1... i i i i i i T T T T T T T

Divide-d-Coquer 19 teger Mutipictio Agoritm: Mutipy two -it itegers d. Divide step: Spit d ito ig-order d ow-order its We c te deie * y mutipyig te prts d ddig: So, T 4T, wic impies T is O. But tt is o etter t te goritm we ered i grde scoo. * *

Divide-d-Coquer 0 A mproved teger Mutipictio Agoritm Agoritm: Mutipy two -it itegers d. Divide step: Spit d ito ig-order d ow-order its Oserve tt tere is deret wy to mutipy prts: So, T 3T, wic impies T is O 3, y te Mster Teorem. Tus, T is O 1.585. ] [ ] [ *