Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
219 views
Recurrence Tree
Recurrence Tree
Uploaded by
amukhopadhyay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save Recurrence Tree For Later
Download
Save
Save Recurrence Tree For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
219 views
Recurrence Tree
Recurrence Tree
Uploaded by
amukhopadhyay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save Recurrence Tree For Later
Carousel Previous
Carousel Next
Save
Save Recurrence Tree For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 6
Search
Fullscreen
88 Chaprer 4 Divide-and-Conguer 439 Solve the recurrence T(n) = 31) + logn by making a change of variables, Your solution should be asymptotically tight. Do not worry about whether values ave integral method for Although you can use the substitution method to provide a succinct proof that a solution to a recurrence is correct, you might have trouble coming up with a good guess. Drawing out a recursion tree, as we did in our analysis of the merge sort recurrence in Section 2.3.2, serves as a straightforward way to devise a good guess. In a recursion tree, each node represents the cost of a single subproblem somewhere in the set of recursive function invocations. We sum the costs within each level of the tree to obtain a set of per-level costs, and then we sum alll the ‘per-level costs to determine the total cost of all levels of the recursion. A recursion tree is best used to generate a good guess, which you can then verify by the substitution method. When using a recursion tree to generate a good guess, you can ofien tolerate a small amount of “sloppiness,” since you will be verifying your guess later on. If you are very careful when drawing out a recursion tree and summing the costs, however, you can use a recursion tree as a direct proof of a solution to a recurrence. In this section, we will use recursion trees to generate good guesses, and in Section 4.6, we will use recursion trees directly to prove the theorem that forms the basis of the master method. For example, let us see how a recursion tree would provide a good guess for the recurrence Tn) = 37(|n/4|) | @(a2). We start by focusing on finding an upper bound for the solution. Because we know that floors and ceilings usually do not matter when solving recurrences (here’s an example of sloppiness that we can tolerate), We create a recursion tree for the recurrence T(n) = 31 (n/4) | en, having written out the implied constant coefficient ¢ > 0. Figure 4.5 shows how we derive the recursion tree for T(n) = 37(n/4) ~ en. For convenience, we assume that n is an exact power of 4 (another example of tolerable sloppiness) so that all subproblem sizes are integers. Part (a) of the figure shows T(mn), which we expand in part (b) into an equivalent tree representing the recurrence. The cn? term at the root represents the cost at the top level of recursion, and the three subtrees of the root represent the costs incurred by the subproblems of size n/4, Part (c) shows this process carried one step further by expanding each node with cost T(n/4) from part (b). The cost for each of the three children of the root is c(n/4)*. We continue expanding each node in the tree by breaking it into its constituent parts as determined by the recurrence.44 The recursion-iree method for solving recurrences 9 Tin) en /\\ Tie) THE) TR) cay cay J... LS T(z) Te) Tae) Th ©) Tie Tie) @ © © cay en? Ta) TA) TU) TE) TO) TA) TA) TAY TU) TU) TAY TA) TA) O(n) @ Toul: O10") Figure 4.5 Constructing a recursion tree for the recurrence T(n) = 3T(n/4) = en®. Part (a) shows 7 (), which progressively expands in (b}~14) to form the recursion tee. The fully expanded tree in part () has height logy m (it has logy n ~ 1 levels.90 Chaprer 4 Divide-and-Conguer Because subproblem sizes decrease by a factor of 4 each time we go down one level, we eventually must reach a boundary condition. How far from the root do we reach one? The subproblem size for a node at depth i is m/4'. Thus, the ‘subproblem size hits m = I when n/4! = 1 or, equivalently, when i = loggn. Thus, the tree has log, 1" + I levels (at depths 0, 1,2,... .log,m). Next we determine the cost at each level of the tree. Each level has three times, ‘more nodes thun the evel above, and so dhe numer of nodes at depth 7 is 3 se subproblem sizes reduce by a factor of 4 for each level we go down from the root, each node at depth i, for? = 0,1,2,..2,logym — I, has a cost ‘of e(n/4')®, Multiplying, we see that the fotal cost over all nodes at depth i, for i = 0,1.2,...,logen — 1, is 8e(n/4')? = (B/16)'en. The bottom level, at depth log, n, has 3°" — n> nodes, each contributing cost T(1), for a'total cost of n=" 7 (1), which is @(n"*"), since we assume that T(1) is a constant. Now we add up the costs over all levels to determine the cost for the entire tree: T 2 3 on (ZY ent 3 eyghee® 0) = or a eo (B) em anne (Bf a 0m =F Ayer em 7 On) (by caution Gem “ay—T* This lst formula looks somewhat messy until we realize that advantage of small amounts of sloppiness and use an infinite decreasing geometric ies as an upper bound. Backing up one step and applying equation (A.6), we have ‘an again take 3) Ta = (=) en? + O(n'=3) 3 (2) en? Ines3 < Lz) en + (nh) - 1 une = oe on) 16 2 nie? = Fer oui) = O(n) ‘Thus, we have derived a guess of T(n) = O(n?) for our original recurrence T(n) = 31 (|n/4)) + O(n). In this example, the coefficients of en? form a decreasing geometric series and, by equation (A.6), the sum of these coefficients4A The recursion-tree method for solving recurrences or oN : ea) oF / \ / \ ee) Ge Total: O(n Figure 4.6 A recursion tee forthe recurrence Tan) = T(n/3) + TQn/3) en. is bounded from above by the constant 16/13. Since the root's contribution to the total cost is cn?, the root contributes a constant fraction of the total cost. In other words, the cost of the root dominates the total cost of the tree. In fact, if O(n2) is indeed an upper bound for the recurrence (as we shall verify in momen, then it must be a tight bound. Why? The first I contributes a cost of @(n7), and so ©)(7;2) must be a lower bound for the recurrence. Now we ean use the substitution method to verify that our guess was cor ‘rect, that is, T(m) = O(n?) is an upper bound for the recurrence T(n) = “1 (0). We want to show that T(n) = dn? for some constant d > 0, Using the same constant ¢ > 0 as before, we have Tin) = 37(\n/4)) +en? 3d [n/4)? + en? = 3d(n/4)? + en? 3 = Sdn? en 16 = dn?, where the last step holds as long as d > (16/13)c In another, more intricate, example, Figure 4.6 shows the recursion tree for T(n) =T(n/3) + TQn/3) ~ O(n) (Again, we omit floor and ceiling functions for simplicity.) As before, we let ¢ represent the constant factor in the O(7) term. When we add the values across the levels of the recursion tree shown in the figure, we get a value of en for every level.2 Chaprer 4 Divide-and-Conguer The longest simple path from the root to a leaf ism + (2/3) > (2/3)'m » 1. Since (2/3)kn = 1 when k = logsy2., the height of the tree is logs, Intuitively, we expect the solution to the recurrence to be at most the number of levels times the cost of each level, or O(cn logan) = O(n ign). Figure 4.6 shows only the top levels of the recursion tree, however, and not every level in the tree contributes a cost of ext. Consider the cost of the leaves. If this recursion tree were a complete binary tree of height logaj27, there would be 2659/2" = n'e/2? leaves. Since the cost of each leaf is a constant, the total cost of all leaves would then be @(n'*327) which, since log3/22 is a constant strictly greater than 1, is w(n Ign). This recursion tree is not a complete binary tree, however, and so it has fewer than n=? leaves. Moreover, as we go down from the root, more and more internal nodes are absent. Consequently, levels toward the bottom of the recursion tree contribute less than cv to the total cost. We could work out an accu rate accounting of all costs, but remember that we are just trying to come up with a guess to use in the substitution method. Let us tolerate the sloppiness and attempt to show that a guess of O(n Ig) for the upper bound is correct. Indeed, we can use the substitution method to verify that O(r Ig.) is an upper bound for the solution to the recurrence. We show that T(n) < dn ign, where d is a suitable positive constant. We have Tin) = T(n/3) 4 TQn/3) -en = d(n/3)1g(x/3) + d2n/3) 1g(2n/3) + en = (d(n/3)lgn —d(n/3) 1g 3) + (dQn/3) 1g — d(2n/3)1g(3/2)) 4 en = dnign —d((n/3)1g3 + 2n/3)1g(3/2)) ~ en dn ign —d((n/3)1g3 | (2n/3)1g3 —2n/3)1g2) en = dnign—dn(lg3—2/3) +n dnign, aslongas d » accounting o! ¢/(lg3—(2/3)). Thus, we did not need to perform a more accurate ts in the recursion tree. Exercises. 44-1 Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n) = 3T (\n/2|) 4 n. Use the substitution method to verify your answer, 442 Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n) = T(n/2) +12. Use the substitution method to verily your answer.45° The master method for solving recurrences 93 43 Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n) =4T(n/2 4 2) 4 n. Use the substitution method to verify your answer. 444 Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n) = 21 (n = 1) + L. Use the substitution method to verify your answer. Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n) = T(n=1) +7 (n/2)-+n. Use the substitution method to verify your answer. 46 Argue that the solution to the recurrence T(n) = T(n/3) +T(Qn/3)-+en, where c is a constant, is (0 lg) by appealing to a recursion tree. 447 Draw the recursion tree for T(n) = 47(|n/2|) + en, where ¢ is a constant, and provide a tight asymptotic bound on its solution. Verify your bound by the substi- tution method. 448 Use a recursion tree to give an asymptotically tight solution to the recurrence T(n) =T(n —a) + T(a) + en, where a > 1 and ¢ > 0 are constants 449 Use a recursion tree to give an asymptotically tight solution to the recurrence T(n) = Tan) ~T (0 —ain)-+ en, where «isa constant in the range () = @ = | and ¢ > Os also a constant. 4.5. The master method for solving recurrences ‘The master method provides a “cookbook” method for solving recurrences of the form T(n) =aT(n/b) + fin). (4.20) where @ > 1 and b > 1 are constants and f(n) is an asymptotically positive function. To use the master method, you will need to memorize th . but then you will be able to solve many recurrences quite easily, often without pencil and paper.
You might also like
Ford Inyeccion Fiesta Courier Ka Rocam Eec V Sfi 60 Pines PDF
PDF
90% (10)
Ford Inyeccion Fiesta Courier Ka Rocam Eec V Sfi 60 Pines PDF
2 pages
01 - Motion in A Striaght Line Hans Ohanian
PDF
No ratings yet
01 - Motion in A Striaght Line Hans Ohanian
11 pages
Eheim 2080 Professional 3
PDF
100% (1)
Eheim 2080 Professional 3
18 pages
Complex Variables Slides IITG
PDF
No ratings yet
Complex Variables Slides IITG
54 pages
Workshop Day1
PDF
No ratings yet
Workshop Day1
65 pages
Bab Pondasi Dalam - Braja M. Das (Sub Bab 11.11-11.13)
PDF
No ratings yet
Bab Pondasi Dalam - Braja M. Das (Sub Bab 11.11-11.13)
16 pages
M03 Phys SB Ethy12 0223 U03
PDF
No ratings yet
M03 Phys SB Ethy12 0223 U03
33 pages
Preventive Maintenance and Lubrication Meritor Rear Axle
PDF
No ratings yet
Preventive Maintenance and Lubrication Meritor Rear Axle
15 pages
Elasticidad Precio de La Demanda
PDF
No ratings yet
Elasticidad Precio de La Demanda
9 pages
Elasticidad Precio de La Demanda
PDF
No ratings yet
Elasticidad Precio de La Demanda
9 pages
M08 Phys SB Ethg11 0209 U08
PDF
No ratings yet
M08 Phys SB Ethg11 0209 U08
42 pages
Factores Que Influyen en La Compra.
PDF
No ratings yet
Factores Que Influyen en La Compra.
21 pages
DC Self-Excited Shunt and Series Generator
PDF
No ratings yet
DC Self-Excited Shunt and Series Generator
15 pages
P320 General
PDF
No ratings yet
P320 General
5 pages
Aggregate Impact Value
PDF
No ratings yet
Aggregate Impact Value
3 pages
lecture 3 capablity
PDF
No ratings yet
lecture 3 capablity
21 pages
lecture 4 capablity
PDF
No ratings yet
lecture 4 capablity
21 pages
Thermodynamics Onkar Singh
PDF
No ratings yet
Thermodynamics Onkar Singh
18 pages
KRF15
PDF
No ratings yet
KRF15
1 page
Distribucion 2018 - BTPLUG
PDF
No ratings yet
Distribucion 2018 - BTPLUG
4 pages
Free Time Activities 10-10 TK
PDF
No ratings yet
Free Time Activities 10-10 TK
8 pages
Копия Workers are losing their chains
PDF
No ratings yet
Копия Workers are losing their chains
1 page
Swanganzparte2 PDF
PDF
No ratings yet
Swanganzparte2 PDF
7 pages
1199 2638 1 SM - Unlocked
PDF
No ratings yet
1199 2638 1 SM - Unlocked
7 pages
Algebra Intermedia Angel Allen Cap. 3.2 - Funciones 7ma Ed.
PDF
No ratings yet
Algebra Intermedia Angel Allen Cap. 3.2 - Funciones 7ma Ed.
15 pages
Advanced Soil Mechanics - Braja Das - Consolidacao
PDF
No ratings yet
Advanced Soil Mechanics - Braja Das - Consolidacao
19 pages
Grauer Weil Article Business India
PDF
No ratings yet
Grauer Weil Article Business India
5 pages
[ASME]_ASME_B31.12-2008
PDF
No ratings yet
[ASME]_ASME_B31.12-2008
258 pages
ASME B31.12 - 2008 (Hydrogen Piping and Pipeline)
PDF
No ratings yet
ASME B31.12 - 2008 (Hydrogen Piping and Pipeline)
258 pages
Vw Transmisión Passat Variant 2.8 v6 Aeb Automatic Getrieb A
PDF
No ratings yet
Vw Transmisión Passat Variant 2.8 v6 Aeb Automatic Getrieb A
1 page
Distribucion 2018 - MEGATIKER
PDF
No ratings yet
Distribucion 2018 - MEGATIKER
36 pages
SMR Taludes
PDF
No ratings yet
SMR Taludes
3 pages
Boeco MC 24
PDF
No ratings yet
Boeco MC 24
1 page
Bomba Reciprocante Gaso 1800 Duplex Piston Pump
PDF
100% (2)
Bomba Reciprocante Gaso 1800 Duplex Piston Pump
2 pages
VW Transmisión Automática Bora Ag4 PDF
PDF
No ratings yet
VW Transmisión Automática Bora Ag4 PDF
1 page
Journeys
PDF
No ratings yet
Journeys
16 pages
Gard GT8
PDF
No ratings yet
Gard GT8
6 pages
Ford f350
PDF
No ratings yet
Ford f350
60 pages
Resenha - Mal estar, sofrimento e sintoma
PDF
No ratings yet
Resenha - Mal estar, sofrimento e sintoma
8 pages
Business Startup Guides-Preparing Yourself Ver 2
PDF
100% (1)
Business Startup Guides-Preparing Yourself Ver 2
4 pages
VW Transmisión Automática New Beetle Ag4 PDF
PDF
No ratings yet
VW Transmisión Automática New Beetle Ag4 PDF
1 page
Exemplos - Equilíbrio de Uma Partícula
PDF
No ratings yet
Exemplos - Equilíbrio de Uma Partícula
8 pages
Substitution Method
PDF
No ratings yet
Substitution Method
6 pages
Vw Transmisión Automática Golf 1997 PDF
PDF
No ratings yet
Vw Transmisión Automática Golf 1997 PDF
1 page
Distribucion 2018 - TABLEROS DE ALUMBRADO
PDF
No ratings yet
Distribucion 2018 - TABLEROS DE ALUMBRADO
14 pages
14 Partial Derivatives 1
PDF
No ratings yet
14 Partial Derivatives 1
24 pages
Super Fi Cies
PDF
No ratings yet
Super Fi Cies
6 pages
Geography - Food From Around The World 53
PDF
No ratings yet
Geography - Food From Around The World 53
1 page
A320 Inlet Cowling Repair No. 1 Replacement of Aerodynamic Sealant
PDF
No ratings yet
A320 Inlet Cowling Repair No. 1 Replacement of Aerodynamic Sealant
6 pages
VW Inyección Electónica Gol Parati 1.8 Mi 1997-07-1998 Magn
PDF
No ratings yet
VW Inyección Electónica Gol Parati 1.8 Mi 1997-07-1998 Magn
2 pages
Partes Vogele 2017
PDF
100% (6)
Partes Vogele 2017
118 pages
2sd2162_nec
PDF
No ratings yet
2sd2162_nec
6 pages
476-729-1-SM
PDF
No ratings yet
476-729-1-SM
13 pages
008914130
PDF
No ratings yet
008914130
11 pages
Critical Thinking - Chapter 4
PDF
No ratings yet
Critical Thinking - Chapter 4
33 pages
VW Inyección Electónica Gol Parati Saveiro 1.8 Mi 07-1998 M
PDF
No ratings yet
VW Inyección Electónica Gol Parati Saveiro 1.8 Mi 07-1998 M
2 pages
Astm D 1654 Evalution of Pinted or Coted Specimen
PDF
No ratings yet
Astm D 1654 Evalution of Pinted or Coted Specimen
4 pages
Ta714 QC12
PDF
No ratings yet
Ta714 QC12
1 page
VW Inyección Electrónica Bora 2.0 Aeg PDF
PDF
No ratings yet
VW Inyección Electrónica Bora 2.0 Aeg PDF
2 pages
See HVAC
PDF
No ratings yet
See HVAC
6 pages
Catálogo Geca Av025fo FR 6bar
PDF
No ratings yet
Catálogo Geca Av025fo FR 6bar
2 pages
Differential Forms
From Everand
Differential Forms
Henri Cartan
5/5 (2)
MCQ XML
PDF
No ratings yet
MCQ XML
5 pages
2nd Class
PDF
No ratings yet
2nd Class
7 pages
String Matching
PDF
100% (1)
String Matching
12 pages
Matrix Chain Multiplication
PDF
No ratings yet
Matrix Chain Multiplication
11 pages
Graph Traversal Algorithm: Recapitulation
PDF
No ratings yet
Graph Traversal Algorithm: Recapitulation
14 pages
Strassen
PDF
No ratings yet
Strassen
8 pages
Disjoint Set
PDF
No ratings yet
Disjoint Set
4 pages
Networking Basics
PDF
No ratings yet
Networking Basics
14 pages
Auto
PDF
No ratings yet
Auto
7 pages
ARQ
PDF
No ratings yet
ARQ
6 pages
Pumping Lemma Note - Get - Easy
PDF
No ratings yet
Pumping Lemma Note - Get - Easy
3 pages
Myhill Nerode
PDF
No ratings yet
Myhill Nerode
10 pages
Transport Layer Notes Module 3
PDF
No ratings yet
Transport Layer Notes Module 3
10 pages
Calibration Problem Minimum No of Control Points
PDF
No ratings yet
Calibration Problem Minimum No of Control Points
1 page
4 Reg Ex
PDF
No ratings yet
4 Reg Ex
26 pages
Choto Didi
PDF
No ratings yet
Choto Didi
1 page
Advanced C Concepts: 2501ICT Nathan
PDF
No ratings yet
Advanced C Concepts: 2501ICT Nathan
32 pages
3 Pipeline
PDF
No ratings yet
3 Pipeline
21 pages
Phase 1: Requirement Analysis and Specification. The Main Task of This Phase Is To
PDF
No ratings yet
Phase 1: Requirement Analysis and Specification. The Main Task of This Phase Is To
19 pages
Mathematics Grade 10 Term 1 Week 6 - 2021
PDF
No ratings yet
Mathematics Grade 10 Term 1 Week 6 - 2021
7 pages
hw1
PDF
No ratings yet
hw1
7 pages
The Asymptotic Behaviour of Semigroups of Linear Operators: Jan Van Neerven
PDF
No ratings yet
The Asymptotic Behaviour of Semigroups of Linear Operators: Jan Van Neerven
241 pages
FYJC Science Question Patter 2023 - 24
PDF
No ratings yet
FYJC Science Question Patter 2023 - 24
13 pages
23-24 Y12 IB Quiz 2
PDF
No ratings yet
23-24 Y12 IB Quiz 2
16 pages
7-Vectors
PDF
No ratings yet
7-Vectors
17 pages
Combined Use of PCA and Prony Analysis For Electromechanical Oscillation Identification
PDF
No ratings yet
Combined Use of PCA and Prony Analysis For Electromechanical Oscillation Identification
9 pages
Spaghetti Sine Curve Activity
PDF
No ratings yet
Spaghetti Sine Curve Activity
2 pages
Kalman Filter: Lecture Notes
PDF
No ratings yet
Kalman Filter: Lecture Notes
9 pages
Maths Class Xii Chapter 09 Differential Equations Practice Paper 11 2024
PDF
No ratings yet
Maths Class Xii Chapter 09 Differential Equations Practice Paper 11 2024
3 pages
Frequency Domain
PDF
No ratings yet
Frequency Domain
37 pages
Calculus Concepts and Contexts 4th Edition Stewart Solutions Manual instant download
PDF
100% (1)
Calculus Concepts and Contexts 4th Edition Stewart Solutions Manual instant download
54 pages
Instant download (Ebook) McDougal Littell Algebra 2 by Holt McDougal, Ron Larson, Laurie Boswell, Timothy D. Kanold, Lee Stiff ISBN 9780547315263, 0547315260 pdf all chapter
PDF
100% (1)
Instant download (Ebook) McDougal Littell Algebra 2 by Holt McDougal, Ron Larson, Laurie Boswell, Timothy D. Kanold, Lee Stiff ISBN 9780547315263, 0547315260 pdf all chapter
67 pages
AE420 Chpt8 Fall 2021
PDF
No ratings yet
AE420 Chpt8 Fall 2021
20 pages
Maximum or Minimum of A Polynomial
PDF
No ratings yet
Maximum or Minimum of A Polynomial
4 pages
Dynamic Programming
PDF
No ratings yet
Dynamic Programming
5 pages
FEA Notes - 22
PDF
No ratings yet
FEA Notes - 22
77 pages
Bascal
PDF
No ratings yet
Bascal
16 pages
Am GM
PDF
No ratings yet
Am GM
58 pages
lund-university-faculty-of-science-info-sheet-2020-2021-2
PDF
No ratings yet
lund-university-faculty-of-science-info-sheet-2020-2021-2
18 pages
Assessment 1 - Maple Lab Assignment (March-Ogos 2023)
PDF
No ratings yet
Assessment 1 - Maple Lab Assignment (March-Ogos 2023)
4 pages
Professor Teuvo Kohonen (Auth.) Self-Organizing Maps
PDF
100% (1)
Professor Teuvo Kohonen (Auth.) Self-Organizing Maps
437 pages
06 Smoothing PDF
PDF
No ratings yet
06 Smoothing PDF
55 pages
ME Math 10 Q2 0801 SG
PDF
No ratings yet
ME Math 10 Q2 0801 SG
16 pages
Frame Element
PDF
No ratings yet
Frame Element
6 pages
1.1 Discounted (Infinite-Horizon) Markov Decision Processes
PDF
No ratings yet
1.1 Discounted (Infinite-Horizon) Markov Decision Processes
26 pages
Sankalp-Maths - Revision Plan
PDF
No ratings yet
Sankalp-Maths - Revision Plan
4 pages
A Deeper View of Calculus by Richard J Bagby
PDF
100% (1)
A Deeper View of Calculus by Richard J Bagby
219 pages