Algorithms and Data Structures Lecture IV

Size: px
Start display at page:

Download "Algorithms and Data Structures Lecture IV"

Transcription

1 Algorithms ad Data Structures Lecture IV Simoas Šalteis Aalborg Uiversity September 5, 00 1

2 This Lecture Aalyzig the ruig time of recursive algorithms (such as divide-ad-coquer) Writig ad solvig recurreces September 5, 00

3 Recurreces Ruig times of algorithms with Recursive calls ca be described usig recurreces A recurrece is a equatio or iequality that describes a fuctio i terms of its value o smaller iputs. For divide-ad-coquer algorithms: solvig_trivial_problem if = 1 T ( ) = um_pieces T ( / subproblem_size_factor) + dividig + combiig if > 1 Example: Merge Sort T ( ) Θ (1) if = 1 = T ( /) +Θ ( ) if > 1 September 5, 00 3

4 Solvig Recurreces Repeated (backward) substitutio method Expadig the recurrece by substitutio ad oticig a patter Substitutio method guessig the solutios verifyig the solutio by the mathematical iductio Recursio-trees Master method templates for differet classes of recurreces September 5, 00 4

5 Repeated Substitutio Let s fid the ruig time of the merge sort (let s assume that = b, for some b). 1 if = 1 T( ) = T( /) + if > 1 ( ) T( / 4 ) / expad T ( ) = T/ + substitute ( ) = + + = + T ( / 4) substitute = + + ( T ( /8) / 4) expad 3 T ( /8) 3 observe the patter = + T ( ) = i i T ( / ) + i = lg T ( / ) + lg = + lg September 5, 00 5

6 Repeated Substitutio Method The procedure is straightforward: Substitute Expad Substitute Expad Observe a patter ad write how your expressio looks after the i-th substitutio Fid out what the value of i (e.g., lg) should be to get the base case of the recurrece (say T(1)) Isert the value of T(1) ad the expressio of i ito your expressio September 5, 00 6

7 Repeated Substitutio (Ex. ) Let s fid a more exact ruig time of merge sort (let s assume that = b, for some b). T( ) if = 1 = T( /) if > 1 ( ) T( ) ( ) T( ) T ( ) = T/ substitute ( ) = / expad = T / substitute ( ) = / 8 / expad ( ) ( ) = T / observe the patter i 1 i i j T ( ) = T ( / ) + i+ 3 j= 0 = + + = + lg lg T ( / ) lg 3( 1) 5 lg 3 September 5, 00 7

8 Repeated Substitutio (Ex. 3) Let s fid the ruig time of the tromio tilig algorithm for a x board. T( ) 1 if = 1 = 4 T( 1) + 1 if > 1 T ( ) 44 ( T( ) 1) 1 expad 4 T( ) 4 1 substitute 4 ( 4T( 3) 1) 4 1 expad T ( ) = substitute = + + = + + = ( ) ( ) = T observe the patter i 1 i T ( ) = 4 T ( i) + 4 j= = 4 T (1) + = j September 5, 00 8

9 Substitutio method Solve T ( ) = 4 T ( / ) + 1) Guess that T ( ) = O ( ), i.e., that Tof the form c 3 ) Assume Tk ( ) ck for k / ad 3 3) Prove T ( ) c by iductio 3 3 T ( ) = 4 T ( / ) + (recurrece) T 3 4c(/) (id. hypoth.) + 3 Thus ( ) ( )! c 3 = + (simplify) 3 c 3 = c (rearrage) 3 c if c ad 1 (satisfy) = O Subtlety: Must also check the base case (ot ecessarily T (1)) September 5, 00 9

10 Substitutio Method Achievig tighter bouds T Try to show ( ) ( ) Assume Tk ( ) ck T ( ) = 4 T ( /) + + 4( c/) = + c = O > c for o choice of c 0. September 5, 00 10

11 Substitutio Method () The problem? We could ot rewrite the equality as: T = ( ) c+ (somethig positive) T ( ) c i order to show the iequality we wated Sometimes to prove iductive step, try to stregthe your hypothesis T() (aswer you wat) - (somethig > 0) September 5, 00 11

12 Substitutio Method (3) Corrected proof: the idea is to stregthe the iductive hypothesis by subtractig lower-order terms! Assume Tk ( ) ck 1 ck for k< T ( ) = 4 T ( /) + 4( c ( / ) c ( / )) + = c c+ = c c ( c ) c cif c September 5, 00 1

13 Recursio Tree A recursio tree is a coveiet way to visualize what happes whe a recurrece is iterated Good for guessig asymtotic solutios to recurreces T ( ) = T ( /4) + T ( /) + September 5, 00 13

14 Recursio Tree () September 5, 00 14

15 Master Method The idea is to solve a class of recurreces that have the form T ( ) = atb ( / ) + f ( ) a 1ad b > 1, ad f is asymptotically positive. Abstractly speakig, T() is the rutime for a algorithm ad we kow that a subproblems of size /b are solved recursively, each i time T(/b) f() is the cost of dividig the problem ad combiig the results. I merge-sort T ( ) = T ( /) +Θ( ) September 5, 00 15

16 Master Method () Split problem ito a parts at log b logb logba levels. There are a = leaves September 5, 00 16

17 Master Method (3) Number of leaves: a log Iteratig the recurrece, expadig the tree yields T ( ) = f ( ) + atb ( / ) The first term is a divisio/recombiatio cost (totaled across all levels of the tree) log The secod term is the cost of doig all b a subproblems of size 1 (total of all work pushed to leaves) b = log = f + af b + a T b ( ) ( / ) ( / ) = f + af b + a T b + ( ) ( / ) ( / )... logb 1 logb 1 logb + a f( / b ) + a T(1) Thus, logb 1 j j logb a ( ) = ( / ) +Θ( ) T afb j= 0 b a September 5, 00 17

18 MM Ituitio Three commo cases: Ruig time domiated by cost at leaves Ruig time evely distributed throughout the tree Ruig time domiated by cost at the root Cosequetly, to solve the recurrece, we eed oly to characterize the domiat term logb I each case compare f( ) with O ( a ) September 5, 00 18

19 MM Case 1 logb a ε f( ) = O( ) for some costat ε > 0 f() grows polyomially (by factor ) slower log tha b a The work at the leaf level domiates logb a Summatio of recursio-tree levels O ( ) logb a Cost of all the leaves Θ( ) logb a Thus, the overall cost Θ( ) ε September 5, 00 19

20 MM Case logb f( ) =Θ( a ) log ( ) ad b a are asymptotically the same f The work is distributed equally logb a throughout the tree T ( ) =Θ( lg ) (level cost) (umber of levels) September 5, 00 0

21 MM Case 3 logb a+ε f( ) =Ω( ) for some costat Iverse of Case 1 f() grows polyomially faster tha Also eed a regularity coditio log b a c < 1 ad > 0 such that af ( / b) cf ( ) > 0 0 The work at the root domiates T ( ) =Θ( f ( )) ε > 0 September 5, 00 1

22 Master Theorem Summarized Give a recurrece of the form 1. f( ) = O T ( ) =Θ. f( ) =Θ logb a ε ( ) logb a ( ) logb a ( ) logb a ( ) logb a+ε ( ) T ( ) =Θ lg ( f) T ( ) = atb ( / ) + f ( ) 3. f( ) =Ω ad af( / b) cf( ), for some c< 1, > T ( ) =Θ ( ) The master method caot solve every recurrece of this form; there is a gap betwee cases 1 ad, as well as cases ad 3 September 5, 00 0

23 Strategy Extract a, b, ad f() from a give recurrece Determie log b a Compare f() ad asymptotically Determie appropriate MT case, ad apply Example merge sort T ( ) = T ( /) +Θ( ) log b a a= b= = = =Θ Also f( ) =Θ( ) log b a log, ; ( ) ( log ) b a ( ) Case : T ( ) =Θ lg =Θ lg September 5, 00 3

24 Examples of MM T ( ) = T ( / ) + 1 a = b= = log1 1, ; 1 also f( ) = 1, f( ) =Θ(1) Case : T ( ) =Θ(lg ) Biary-search(A, p, p, r, r, s): s): q (p+r)/ if if A[q]=s the the retur q else else if if A[q]>s the the Biary-search(A, p, p, q-1, q-1, s) s) else else Biary-search(A, q+1, q+1, r, r, s) s) T ( ) = 9 T ( /3) + a = 9, b= 3; f = f = O ε= log3 9 ε ( ), ( ) ( ) with 1 Case 1: T ( ) =Θ ( ) September 5, 00 4

25 Examples () T ( ) = 3 T ( /4) + lg = 3, = 4; = 4 a b log log4 3+ε ( ) lg, ( ) ( ) with 0. f = f =Ω ε Case 3: Regularity coditio af ( / b) = 3( /4)lg( / 4) (3/ 4) lg = cf ( ) for c = 3/ 4 T ( ) =Θ( lg ) T ( ) = T ( /) + lg =, = ; = a b log 1 1+ε f ( ) = lg, f( ) =Ω( ) with ε? also l 1 g / lg = either Case 3 or Case! September 5, 00 5

26 Examples: Multiplicatio (I) Multiplyig two -digit (or -bit) umbers costs digit multiplicatios usig a classical procedure. Observatio: 3*14 = ( )*( ) = (*1)10 + (3*1 + *4) (3*4) To save oe multiplicatio we use a trick: (3*1 + *4) = (+3)*(1+4) - (*1) - (3*4) September 5, 00 6

27 Examples: Multiplicatio (II) To multiply a ad b, which are -digit umbers, we use a divide ad coquer algorithm. We split them i half: a = a 1 10 / + a 0 ad b = b 1 10 / + b 0 The: a *b = (a 1 *b 1 )10 + (a 1 *b 0 + a 0 *b 1 )10 / + (a 0 *b 0 ) Use a trick to save a multiplicatio: (a 1 *b 0 + a 0 *b 1 ) =(a 1 +a 0 )*(b 1 +b 0 ) - (a 1 *b 1 ) - (a 0 *b 0 ) September 5, 00 7

28 Examples: Multiplicatio (III) The umber of sigle-digit multiplicatios performed by the algorithm ca be described by a recurrece: T( ) Solutio: 1 if = 1 = 3 T( /) if > 1 T( ) = = log September 5, 00 8

29 Next Week Sortig QuickSort HeapSort September 5, 00 9

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

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2 This Lecture Divide-ad-coquer techique for algorithm desig. Example the merge sort. Writig ad solvig recurreces Divide ad Coquer Divide-ad-coquer method for algorithm desig: Divide: If the iput size is

More information

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

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides CS583 Lecture 02 Jaa Kosecka some materials here are based o E. Demaie, D. Luebke slides Previously Sample algorithms Exact ruig time, pseudo-code Approximate ruig time Worst case aalysis Best case aalysis

More information

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

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication Next. Covered bsics of simple desig techique (Divided-coquer) Ch. of the text.. Next, Strsse s lgorithm. Lter: more desig d coquer lgorithms: MergeSort. Solvig recurreces d the Mster Theorem. Similr ide

More information

Data Structures and Algorithm. Xiaoqing Zheng

Data Structures and Algorithm. Xiaoqing Zheng Data Structures ad Algorithm Xiaoqig Zheg zhegxq@fudaeduc What are algorithms? A sequece of computatioal steps that trasform the iput ito the output Sortig problem: Iput: A sequece of umbers

More information

Fundamental Algorithms

Fundamental Algorithms Fudametal Algorithms Chapter 2b: Recurreces Michael Bader Witer 2014/15 Chapter 2b: Recurreces, Witer 2014/15 1 Recurreces Defiitio A recurrece is a (i-equality that defies (or characterizes a fuctio i

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

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

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs. CS23 Algorithms Hadout #6 Prof Ly Turbak September 8, 200 Wellesley College RECURRENCES This hadout summarizes highlights of CLRS Chapter 4 ad Appedix A (CLR Chapters 3 & 4) Two-Step Strategy for Aalyzig

More information

Recurrence Relations

Recurrence Relations Recurrece Relatios Aalysis of recursive algorithms, such as: it factorial (it ) { if (==0) retur ; else retur ( * factorial(-)); } Let t be the umber of multiplicatios eeded to calculate factorial(). The

More information

Algorithms Design & Analysis. Divide & Conquer

Algorithms Design & Analysis. Divide & Conquer Algorithms Desig & Aalysis Divide & Coquer Recap Direct-accessible table Hash tables Hash fuctios Uiversal hashig Perfect Hashig Ope addressig 2 Today s topics The divide-ad-coquer desig paradigm Revised

More information

CS 332: Algorithms. Quicksort

CS 332: Algorithms. Quicksort CS 33: Aorithms Quicsort David Luebe //03 Homewor Assiged today, due ext Wedesday Will be o web page shortly after class Go over ow David Luebe //03 Review: Quicsort Sorts i place Sorts O( ) i the average

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Desig ad Aalysis of Algorithms CSE 53 Lecture 9 Media ad Order Statistics Juzhou Huag, Ph.D. Departmet of Computer Sciece ad Egieerig Dept. CSE, UT Arligto CSE53 Desig ad Aalysis of Algorithms Medias ad

More information

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

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro COMP26120: More o the Complexity of Recursive Programs (2018/19) Lucas Cordeiro lucas.cordeiro@machester.ac.uk Divide-ad-Coquer (Recurrece) Textbook: Algorithm Desig ad Applicatios, Goodrich, Michael T.

More information

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia)

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia) 1 CS 332: Algorithms Liear-Time Sortig. Order statistics. Slide credit: David Luebke (Virgiia) Quicksort: Partitio I Words Partitio(A, p, r): Select a elemet to act as the pivot (which?) Grow two regios,

More information

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

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication Itroductio to Algorithms 6.046J/8.40J LECTURE 3 Divide ad coquer Biary search Powerig a umber Fiboacci umbers Matrix multiplicatio Strasse s algorithm VLSI tree layout Prof. Charles E. Leiserso The divide-ad-coquer

More information

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm:

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: The maximum-subarray problem Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: Brute force algorithm: At best, θ(n 2 ) time complexity 129 Can we do divide

More information

4.3 Growth Rates of Solutions to Recurrences

4.3 Growth Rates of Solutions to Recurrences 4.3. GROWTH RATES OF SOLUTIONS TO RECURRENCES 81 4.3 Growth Rates of Solutios to Recurreces 4.3.1 Divide ad Coquer Algorithms Oe of the most basic ad powerful algorithmic techiques is divide ad coquer.

More information

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

CSE Introduction to Parallel Processing. Chapter 3. Parallel Algorithm Complexity Dr. Izadi CSE-40533 Itroductio to Parallel Processig Chapter 3 Parallel Algorithm Complexity Review algorithm complexity ad various complexity classes Itroduce the otios of time ad time-cost optimality

More information

Lecture 7: Solving Recurrences

Lecture 7: Solving Recurrences Lecture 7: Solvig Recurreces CSE 7: Data Structures ad Algorithms CSE 7 19 WI KASEY CHAMPION 1 Warm Up Writig Recurreces CSE 7 19 WI KASEY CHAMPION 2 Admiistriva HW 2 Part 1 due Friday git ruers will get

More information

Lecture 3: Asymptotic Analysis + Recurrences

Lecture 3: Asymptotic Analysis + Recurrences Lecture 3: Asymptotic Aalysis + Recurreces Data Structures ad Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Write a model ad fid Big-O for (it i = 0; i < ; i++) { for (it j = 0; j < i; j++) { System.out.pritl(

More information

Analysis of Algorithms -Quicksort-

Analysis of Algorithms -Quicksort- Aalysis of Algorithms -- Adreas Ermedahl MRTC (Mälardales Real-Time Research Ceter) adreas.ermedahl@mdh.se Autum 2004 Proposed by C.A.R. Hoare i 962 Worst- case ruig time: Θ( 2 ) Expected ruig time: Θ(

More information

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.5703) ALGORITHM ANALYSIS AND DESIGN (3 cr.) (T) Topics of curret iterest i the desig ad aalysis of computer algorithms for graphtheoretical

More information

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis Recursive Algorithms Recurreces Computer Sciece & Egieerig 35: Discrete Mathematics Christopher M Bourke cbourke@cseuledu A recursive algorithm is oe i which objects are defied i terms of other objects

More information

Data Structures Lecture 9

Data Structures Lecture 9 Fall 2017 Fag Yu Software Security Lab. Dept. Maagemet Iformatio Systems, Natioal Chegchi Uiversity Data Structures Lecture 9 Midterm o Dec. 7 (9:10-12:00am, 106) Lec 1-9, TextBook Ch1-8, 11,12 How to

More information

Test One (Answer Key)

Test One (Answer Key) CS395/Ma395 (Sprig 2005) Test Oe Name: Page 1 Test Oe (Aswer Key) CS395/Ma395: Aalysis of Algorithms This is a closed book, closed otes, 70 miute examiatio. It is worth 100 poits. There are twelve (12)

More information

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

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2 Geeral remarks Week 2 1 Divide ad First we cosider a importat tool for the aalysis of algorithms: Big-Oh. The we itroduce a importat algorithmic paradigm:. We coclude by presetig ad aalysig two examples.

More information

CS / MCS 401 Homework 3 grader solutions

CS / MCS 401 Homework 3 grader solutions CS / MCS 401 Homework 3 grader solutios assigmet due July 6, 016 writte by Jāis Lazovskis maximum poits: 33 Some questios from CLRS. Questios marked with a asterisk were ot graded. 1 Use the defiitio of

More information

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials.

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials. Divide-ad-coquer algorithms Divide & Coquer Strategy: Divide the problem ito smaller subproblems of the same type of problem Solve the subproblems recursively Combie the aswers to solve the origial problem

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

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

CIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5 CIS 11 Data Structures ad Algorithms with Java Sprig 019 Code Sippets ad Recurreces Moday, February 4/Tuesday, February 5 Learig Goals Practice provig asymptotic bouds with code sippets Practice solvig

More information

5. Solving recurrences

5. Solving recurrences 5. Solvig recurreces Time Complexity Alysis of Merge Sort T( ) 0 if 1 2T ( / 2) otherwise sortig oth hlves mergig Q. How to prove tht the ru-time of merge sort is O( )? A. 2 Time Complexity Alysis of Merge

More information

Recurrences: Methods and Examples

Recurrences: Methods and Examples Reurrees: Methods ad Examples CSE 30 Algorithms ad Data Strutures Alexadra Stefa Uiversity of exas at Arligto Updated: 308 Summatios Review Review slides o Summatios Reurrees Reursive algorithms It may

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures ad Algorithms Autum 2017-2018 Outlie 1 Sortig Algorithms (cotd) Outlie Sortig Algorithms (cotd) 1 Sortig Algorithms (cotd) Heapsort Sortig Algorithms (cotd) Have see that we ca build a

More information

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

Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone: Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch Iformatik II Midterm1 Sprig 018 3.03.018 Advice You have 90 miutes to complete

More information

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

Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply: Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch AlgoDat Midterm1 Sprig 016 08.04.016 Name: Matriculatio umber: Advice You have

More information

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

CS 5150/6150: Assignment 1 Due: Sep 23, 2010 CS 5150/6150: Assigmet 1 Due: Sep 23, 2010 Wei Liu September 24, 2010 Q1: (1) Usig master theorem: a = 7, b = 4, f() = O(). Because f() = log b a ε holds whe ε = log b a = log 4 7, we ca apply the first

More information

Chapter 6. Advanced Counting Techniques

Chapter 6. Advanced Counting Techniques Chapter 6 Advaced Coutig Techiques 6.: Recurrece Relatios Defiitio: A recurrece relatio for the sequece {a } is a equatio expressig a i terms of oe or more of the previous terms of the sequece: a,a2,a3,,a

More information

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

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018 CSE 353 Discrete Computatioal Structures Sprig 08 Sequeces, Mathematical Iductio, ad Recursio (Chapter 5, Epp) Note: some course slides adopted from publisher-provided material Overview May mathematical

More information

Mathematical Foundation. CSE 6331 Algorithms Steve Lai

Mathematical Foundation. CSE 6331 Algorithms Steve Lai Mathematical Foudatio CSE 6331 Algorithms Steve Lai Complexity of Algorithms Aalysis of algorithm: to predict the ruig time required by a algorithm. Elemetary operatios: arithmetic & boolea operatios:

More information

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

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc) Classificatio of problem & problem solvig strategies classificatio of time complexities (liear, arithmic etc) Problem subdivisio Divide ad Coquer strategy. Asymptotic otatios, lower boud ad upper boud:

More information

CSE 5311 Notes 1: Mathematical Preliminaries

CSE 5311 Notes 1: Mathematical Preliminaries Chapter 1 - Algorithms Computig CSE 5311 Notes 1: Mathematical Prelimiaries Last updated 1/20/18 12:56 PM) Relatioship betwee complexity classes, eg log,, log, 2, 2, etc Chapter 2 - Gettig Started Loop

More information

Analysis of Algorithms. Introduction. Contents

Analysis of Algorithms. Introduction. Contents Itroductio The focus of this module is mathematical aspects of algorithms. Our mai focus is aalysis of algorithms, which meas evaluatig efficiecy of algorithms by aalytical ad mathematical methods. We

More information

Theorem: Let A n n. In this case that A does reduce to I, we search for A 1 as the solution matrix X to the matrix equation A X = I i.e.

Theorem: Let A n n. In this case that A does reduce to I, we search for A 1 as the solution matrix X to the matrix equation A X = I i.e. Theorem: Let A be a square matrix The A has a iverse matrix if ad oly if its reduced row echelo form is the idetity I this case the algorithm illustrated o the previous page will always yield the iverse

More information

Introduction to Algorithms

Introduction to Algorithms Itroductio to Algorithms 6.046J/8.40J LECTURE 9 Radomly built biary search trees Epected ode depth Aalyzig height Coveity lemma Jese s iequality Epoetial height Post mortem Pro. Eri Demaie October 7, 2005

More information

Math 25 Solutions to practice problems

Math 25 Solutions to practice problems Math 5: Advaced Calculus UC Davis, Sprig 0 Math 5 Solutios to practice problems Questio For = 0,,, 3,... ad 0 k defie umbers C k C k =! k!( k)! (for k = 0 ad k = we defie C 0 = C = ). by = ( )... ( k +

More information

1 Generating functions for balls in boxes

1 Generating functions for balls in boxes Math 566 Fall 05 Some otes o geeratig fuctios Give a sequece a 0, a, a,..., a,..., a geeratig fuctio some way of represetig the sequece as a fuctio. There are may ways to do this, with the most commo ways

More information

Introduction to Algorithms

Introduction to Algorithms Itroductio to Algorithms 6.046J/8.40J/SMA5503 Lecture 9 Pro. Charles E. Leiserso Biary-search-tree sort T Create a empty BST or i to do TREE-INSERT(T, A[i]) Perorm a iorder tree wal o T. Eample: A [3 8

More information

Find a formula for the exponential function whose graph is given , 1 2,16 1, 6

Find a formula for the exponential function whose graph is given , 1 2,16 1, 6 Math 4 Activity (Due by EOC Apr. ) Graph the followig epoetial fuctios by modifyig the graph of f. Fid the rage of each fuctio.. g. g. g 4. g. g 6. g Fid a formula for the epoetial fuctio whose graph is

More information

The Binomial Theorem

The Binomial Theorem The Biomial Theorem Robert Marti Itroductio The Biomial Theorem is used to expad biomials, that is, brackets cosistig of two distict terms The formula for the Biomial Theorem is as follows: (a + b ( k

More information

Complex Numbers Solutions

Complex Numbers Solutions Complex Numbers Solutios Joseph Zoller February 7, 06 Solutios. (009 AIME I Problem ) There is a complex umber with imagiary part 64 ad a positive iteger such that Fid. [Solutio: 697] 4i + + 4i. 4i 4i

More information

APPENDIX F Complex Numbers

APPENDIX F Complex Numbers APPENDIX F Complex Numbers Operatios with Complex Numbers Complex Solutios of Quadratic Equatios Polar Form of a Complex Number Powers ad Roots of Complex Numbers Operatios with Complex Numbers Some equatios

More information

Algorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources

Algorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources Algorithm Aalysis Algorithms that are equally correct ca vary i their utilizatio of computatioal resources time ad memory a slow program it is likely ot to be used a program that demads too much memory

More information

The Growth of Functions. Theoretical Supplement

The Growth of Functions. Theoretical Supplement The Growth of Fuctios Theoretical Supplemet The Triagle Iequality The triagle iequality is a algebraic tool that is ofte useful i maipulatig absolute values of fuctios. The triagle iequality says that

More information

P.3 Polynomials and Special products

P.3 Polynomials and Special products Precalc Fall 2016 Sectios P.3, 1.2, 1.3, P.4, 1.4, P.2 (radicals/ratioal expoets), 1.5, 1.6, 1.7, 1.8, 1.1, 2.1, 2.2 I Polyomial defiitio (p. 28) a x + a x +... + a x + a x 1 1 0 1 1 0 a x + a x +... +

More information

Sect 5.3 Proportions

Sect 5.3 Proportions Sect 5. Proportios Objective a: Defiitio of a Proportio. A proportio is a statemet that two ratios or two rates are equal. A proportio takes a form that is similar to a aalogy i Eglish class. For example,

More information

CSE 332. Data Structures and Parallelism

CSE 332. Data Structures and Parallelism Aam Blak Lecture 6a Witer 2017 CSE 332 Data Structures a Parallelism CSE 332: Data Structures a Parallelism More Recurreces T () T (/2) T (/2) T (/4) T (/4) T (/4) T (/4) P1 De-Brief 1 You i somethig substatial!

More information

CSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability.

CSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability. CSE 0 Homework 1 Matthias Spriger, A9950078 1 Problem 1 Notatio a b meas that a is matched to b. a < b c meas that b likes c more tha a. Equality idicates a tie. Strog istability Yes, there does always

More information

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs CSE 1400 Applied Discrete Mathematics Number Theory ad Proofs Departmet of Computer Scieces College of Egieerig Florida Tech Sprig 01 Problems for Number Theory Backgroud Number theory is the brach of

More information

RADICAL EXPRESSION. If a and x are real numbers and n is a positive integer, then x is an. n th root theorems: Example 1 Simplify

RADICAL EXPRESSION. If a and x are real numbers and n is a positive integer, then x is an. n th root theorems: Example 1 Simplify Example 1 Simplify 1.2A Radical Operatios a) 4 2 b) 16 1 2 c) 16 d) 2 e) 8 1 f) 8 What is the relatioship betwee a, b, c? What is the relatioship betwee d, e, f? If x = a, the x = = th root theorems: RADICAL

More information

Math 21, Winter 2018 Schaeffer/Solis Stanford University Solutions for 20 series from Lecture 16 notes (Schaeffer)

Math 21, Winter 2018 Schaeffer/Solis Stanford University Solutions for 20 series from Lecture 16 notes (Schaeffer) Math, Witer 08 Schaeffer/Solis Staford Uiversity Solutios for 0 series from Lecture 6 otes (Schaeffer) a. r 4 +3 The series has algebraic terms (polyomials, ratioal fuctios, ad radicals, oly), so the test

More information

An Introduction to Randomized Algorithms

An Introduction to Randomized Algorithms A Itroductio to Radomized Algorithms The focus of this lecture is to study a radomized algorithm for quick sort, aalyze it usig probabilistic recurrece relatios, ad also provide more geeral tools for aalysis

More information

Divide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Divide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016 COMPSCI 330: Desig ad Aalysis of Algorithms 1/19/2016 ad 1/21/2016 Lecturer: Debmalya Paigrahi Divide ad Coquer Scribe: Tiaqi Sog 1 Overview I this lecture, a importat algorithm desig techique called divide-ad-coquer

More information

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

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem Lecture 4 Recursive Algorithm Alysis Merge Sort Solvig Recurreces The Mster Theorem Merge Sort MergeSortA, left, right) { if left < right) { mid = floorleft + right) / 2); MergeSortA, left, mid); MergeSortA,

More information

September 2012 C1 Note. C1 Notes (Edexcel) Copyright - For AS, A2 notes and IGCSE / GCSE worksheets 1

September 2012 C1 Note. C1 Notes (Edexcel) Copyright   - For AS, A2 notes and IGCSE / GCSE worksheets 1 September 0 s (Edecel) Copyright www.pgmaths.co.uk - For AS, A otes ad IGCSE / GCSE worksheets September 0 Copyright www.pgmaths.co.uk - For AS, A otes ad IGCSE / GCSE worksheets September 0 Copyright

More information

What Is Required? You need to determine the hydronium ion concentration in an aqueous solution. K w = [H 3 O + ][OH ] =

What Is Required? You need to determine the hydronium ion concentration in an aqueous solution. K w = [H 3 O + ][OH ] = Calculatig the [H3O + ] or [OH ] i Aqueous Solutio (Studet textbook page 500) 11. The cocetratio of hydroxide ios, OH (aq), i a solutio at 5C is 0.150 /. Determie the cocetratio of hydroium ios, H 3 O

More information

Data Structures and Algorithms Chapter 3

Data Structures and Algorithms Chapter 3 Data Structures and Algorithms Chapter 3 1. Divide and conquer 2. Merge sort, repeated substitutions 3. Tiling 4. Recurrences Recurrences Running times of algorithms with recursive calls can be described

More information

Calculus 2 - D. Yuen Final Exam Review (Version 11/22/2017. Please report any possible typos.)

Calculus 2 - D. Yuen Final Exam Review (Version 11/22/2017. Please report any possible typos.) Calculus - D Yue Fial Eam Review (Versio //7 Please report ay possible typos) NOTE: The review otes are oly o topics ot covered o previous eams See previous review sheets for summary of previous topics

More information

( 1) n (4x + 1) n. n=0

( 1) n (4x + 1) n. n=0 Problem 1 (10.6, #). Fid the radius of covergece for the series: ( 1) (4x + 1). For what values of x does the series coverge absolutely, ad for what values of x does the series coverge coditioally? Solutio.

More information

Sums, products and sequences

Sums, products and sequences Sums, products ad sequeces How to write log sums, e.g., 1+2+ (-1)+ cocisely? i=1 Sum otatio ( sum from 1 to ): i 3 = 1 + 2 + + If =3, i=1 i = 1+2+3=6. The ame ii does ot matter. Could use aother letter

More information

Hand Out: Analysis of Algorithms. September 8, Bud Mishra. In general, there can be several algorithms to solve a problem; and one is faced

Hand Out: Analysis of Algorithms. September 8, Bud Mishra. In general, there can be several algorithms to solve a problem; and one is faced Had Out Aalysis of Algorithms September 8, 998 Bud Mishra c Mishra, February 9, 986 Itroductio I geeral, there ca be several algorithms to solve a problem; ad oe is faced with the problem of choosig a

More information

Advanced Course of Algorithm Design and Analysis

Advanced Course of Algorithm Design and Analysis Differet complexity measures Advaced Course of Algorithm Desig ad Aalysis Asymptotic complexity Big-Oh otatio Properties of O otatio Aalysis of simple algorithms A algorithm may may have differet executio

More information

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

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem Lecture 4 Recursive Algorithm Alysis Merge Sort Solvig Recurreces The Mster Theorem Merge Sort MergeSortA, left, right) { if left < right) { mid floorleft right) / 2); MergeSortA, left, mid); MergeSortA,

More information

Divide and Conquer. 1 Overview. 2 Insertion Sort. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Divide and Conquer. 1 Overview. 2 Insertion Sort. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016 COMPSCI 330: Desig ad Aalysis of Algorithms 1/19/2016 ad 1/21/2016 Divide ad Coquer Lecturer: Debmalya Paigrahi Scribe: Tiaqi Sog, Tiayu Wag 1 Overview This set of otes is orgaized as follows. We begi

More information

Mathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis

Mathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis Mathematics review for CSCI 303 Sprig 019 Departmet of Computer Sciece College of William & Mary Robert Michael Lewis Copyright 018 019 Robert Michael Lewis Versio geerated: 13 : 00 Jauary 17, 019 Cotets

More information

Practice Problems: Taylor and Maclaurin Series

Practice Problems: Taylor and Maclaurin Series Practice Problems: Taylor ad Maclauri Series Aswers. a) Start by takig derivatives util a patter develops that lets you to write a geeral formula for the -th derivative. Do t simplify as you go, because

More information

MAT 271 Project: Partial Fractions for certain rational functions

MAT 271 Project: Partial Fractions for certain rational functions MAT 7 Project: Partial Fractios for certai ratioal fuctios Prerequisite kowledge: partial fractios from MAT 7, a very good commad of factorig ad complex umbers from Precalculus. To complete this project,

More information

A B = φ No conclusion. 2. (5) List the values of the sets below. Let A = {n 2 : n P n 5} = {1,4,9,16,25} and B = {n 4 : n P n 5} = {1,16,81,256,625}

A B = φ No conclusion. 2. (5) List the values of the sets below. Let A = {n 2 : n P n 5} = {1,4,9,16,25} and B = {n 4 : n P n 5} = {1,16,81,256,625} CPSC 070 Aswer Keys Test # October 1, 014 1. (a) (5) Defie (A B) to be those elemets i set A but ot i set B. Use set membership tables to determie what elemets are cotaied i (A (B A)). Use set membership

More information

Seunghee Ye Ma 8: Week 5 Oct 28

Seunghee Ye Ma 8: Week 5 Oct 28 Week 5 Summary I Sectio, we go over the Mea Value Theorem ad its applicatios. I Sectio 2, we will recap what we have covered so far this term. Topics Page Mea Value Theorem. Applicatios of the Mea Value

More information

CS161: Algorithm Design and Analysis Handout #10 Stanford University Wednesday, 10 February 2016

CS161: Algorithm Design and Analysis Handout #10 Stanford University Wednesday, 10 February 2016 CS161: Algorithm Desig ad Aalysis Hadout #10 Staford Uiversity Wedesday, 10 February 2016 Lecture #11: Wedesday, 10 February 2016 Topics: Example midterm problems ad solutios from a log time ago Sprig

More information

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) =

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) = AN INTRODUCTION TO SCHRÖDER AND UNKNOWN NUMBERS NICK DUFRESNE Abstract. I this article we will itroduce two types of lattice paths, Schröder paths ad Ukow paths. We will examie differet properties of each,

More information

Real Variables II Homework Set #5

Real Variables II Homework Set #5 Real Variables II Homework Set #5 Name: Due Friday /0 by 4pm (at GOS-4) Istructios: () Attach this page to the frot of your homework assigmet you tur i (or write each problem before your solutio). () Please

More information

COMP285 Midterm Exam Department of Mathematics

COMP285 Midterm Exam Department of Mathematics COMP85 Midterm Exam Departmet of Mathematics Fall 010/011 - November 8, 010 Name: Studet Number: Please fiish withi 90 miutes. All poits above 100 are cosidered as bous poit. You ca reach maximal 1 poits.

More information

TEACHER CERTIFICATION STUDY GUIDE

TEACHER CERTIFICATION STUDY GUIDE COMPETENCY 1. ALGEBRA SKILL 1.1 1.1a. ALGEBRAIC STRUCTURES Kow why the real ad complex umbers are each a field, ad that particular rigs are ot fields (e.g., itegers, polyomial rigs, matrix rigs) Algebra

More information

Math 113 Exam 3 Practice

Math 113 Exam 3 Practice Math Exam Practice Exam will cover.-.9. This sheet has three sectios. The first sectio will remid you about techiques ad formulas that you should kow. The secod gives a umber of practice questios for you

More information

Series: Infinite Sums

Series: Infinite Sums Series: Ifiite Sums Series are a way to mae sese of certai types of ifiitely log sums. We will eed to be able to do this if we are to attai our goal of approximatig trascedetal fuctios by usig ifiite degree

More information

Appendix F: Complex Numbers

Appendix F: Complex Numbers Appedix F Complex Numbers F1 Appedix F: Complex Numbers Use the imagiary uit i to write complex umbers, ad to add, subtract, ad multiply complex umbers. Fid complex solutios of quadratic equatios. Write

More information

Ma 530 Introduction to Power Series

Ma 530 Introduction to Power Series Ma 530 Itroductio to Power Series Please ote that there is material o power series at Visual Calculus. Some of this material was used as part of the presetatio of the topics that follow. What is a Power

More information

ANSWERS SOLUTIONS iiii i. and 1. Thus, we have. i i i. i, A.

ANSWERS SOLUTIONS iiii i. and 1. Thus, we have. i i i. i, A. 013 ΜΑΘ Natioal Covetio ANSWERS (1) C A A A B (6) B D D A B (11) C D D A A (16) D B A A C (1) D B C B C (6) D C B C C 1. We have SOLUTIONS 1 3 11 61 iiii 131161 i 013 013, C.. The powers of i cycle betwee

More information

Math 475, Problem Set #12: Answers

Math 475, Problem Set #12: Answers Math 475, Problem Set #12: Aswers A. Chapter 8, problem 12, parts (b) ad (d). (b) S # (, 2) = 2 2, sice, from amog the 2 ways of puttig elemets ito 2 distiguishable boxes, exactly 2 of them result i oe

More information

Practice Test Problems for Test IV, with Solutions

Practice Test Problems for Test IV, with Solutions Practice Test Problems for Test IV, with Solutios Dr. Holmes May, 2008 The exam will cover sectios 8.2 (revisited) to 8.8. The Taylor remaider formula from 8.9 will ot be o this test. The fact that sums,

More information

ECE-S352 Introduction to Digital Signal Processing Lecture 3A Direct Solution of Difference Equations

ECE-S352 Introduction to Digital Signal Processing Lecture 3A Direct Solution of Difference Equations ECE-S352 Itroductio to Digital Sigal Processig Lecture 3A Direct Solutio of Differece Equatios Discrete Time Systems Described by Differece Equatios Uit impulse (sample) respose h() of a DT system allows

More information

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU. Sortig Algorithms Algorithms Kyuseo Shim SoEECS, SNU. Desigig Algorithms Icremetal approaches Divide-ad-Coquer approaches Dyamic programmig approaches Greedy approaches Radomized approaches You are ot

More information

Polynomials. Computer Programming for Engineers (2014 Spring)

Polynomials. Computer Programming for Engineers (2014 Spring) Computer Programmig for Egieers (014 Sprig) Polyomials Hyougshick Kim Departmet of Computer Sciece ad Egieerig College of Iformatio ad Commuicatio Egieerig Sugkyukwa Uiversity Polyomials A th order polyomial

More information

Assignment 5: Solutions

Assignment 5: Solutions McGill Uiversity Departmet of Mathematics ad Statistics MATH 54 Aalysis, Fall 05 Assigmet 5: Solutios. Let y be a ubouded sequece of positive umbers satisfyig y + > y for all N. Let x be aother sequece

More information

LESSON 2: SIMPLIFYING RADICALS

LESSON 2: SIMPLIFYING RADICALS High School: Workig with Epressios LESSON : SIMPLIFYING RADICALS N.RN.. C N.RN.. B 5 5 C t t t t t E a b a a b N.RN.. 4 6 N.RN. 4. N.RN. 5. N.RN. 6. 7 8 N.RN. 7. A 7 N.RN. 8. 6 80 448 4 5 6 48 00 6 6 6

More information

Chapter 2. Asymptotic Notation

Chapter 2. Asymptotic Notation Asyptotic Notatio 3 Chapter Asyptotic Notatio Goal : To siplify the aalysis of ruig tie by gettig rid of details which ay be affected by specific ipleetatio ad hardware. [1] The Big Oh (O-Notatio) : It

More information

SNAP Centre Workshop. Basic Algebraic Manipulation

SNAP Centre Workshop. Basic Algebraic Manipulation SNAP Cetre Workshop Basic Algebraic Maipulatio 8 Simplifyig Algebraic Expressios Whe a expressio is writte i the most compact maer possible, it is cosidered to be simplified. Not Simplified: x(x + 4x)

More information

Properties and Tests of Zeros of Polynomial Functions

Properties and Tests of Zeros of Polynomial Functions Properties ad Tests of Zeros of Polyomial Fuctios The Remaider ad Factor Theorems: Sythetic divisio ca be used to fid the values of polyomials i a sometimes easier way tha substitutio. This is show by

More information

Induction: Solutions

Induction: Solutions Writig Proofs Misha Lavrov Iductio: Solutios Wester PA ARML Practice March 6, 206. Prove that a 2 2 chessboard with ay oe square removed ca always be covered by shaped tiles. Solutio : We iduct o. For

More information