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)
242 views
6 pages
Recurrence Tree
Recurrence Tree
Uploaded by
amukhopadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
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)
242 views
6 pages
Recurrence Tree
Recurrence Tree
Uploaded by
amukhopadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Carousel Previous
Carousel Next
Download
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
(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
LOE
PDF
No ratings yet
LOE
50 pages
Rao FEM Chap8
PDF
No ratings yet
Rao FEM Chap8
36 pages
Partes Vogele 2017
PDF
100% (6)
Partes Vogele 2017
118 pages
Critical Thinking - Chapter 4
PDF
No ratings yet
Critical Thinking - Chapter 4
33 pages
Factores Que Influyen en La Compra.
PDF
No ratings yet
Factores Que Influyen en La Compra.
21 pages
MarketFailures - BookChapter
PDF
No ratings yet
MarketFailures - BookChapter
19 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
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
M08 Phys SB Ethg11 0209 U08
PDF
No ratings yet
M08 Phys SB Ethg11 0209 U08
42 pages
Resenha - Mal Estar, Sofrimento e Sintoma
PDF
No ratings yet
Resenha - Mal Estar, Sofrimento e Sintoma
8 pages
Super Fi Cies
PDF
No ratings yet
Super Fi Cies
6 pages
Preventive Maintenance and Lubrication Meritor Rear Axle
PDF
No ratings yet
Preventive Maintenance and Lubrication Meritor Rear Axle
15 pages
476 729 1 SM
PDF
No ratings yet
476 729 1 SM
13 pages
Elasticidad Precio de La Demanda
PDF
No ratings yet
Elasticidad Precio de La Demanda
9 pages
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
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
Ford f350
PDF
No ratings yet
Ford f350
60 pages
2sd2162 Nec
PDF
No ratings yet
2sd2162 Nec
6 pages
Hirschsprung Disease
PDF
No ratings yet
Hirschsprung Disease
7 pages
Journeys
PDF
No ratings yet
Journeys
16 pages
P320 General
PDF
No ratings yet
P320 General
5 pages
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
Algorithms Tutorials
PDF
No ratings yet
Algorithms Tutorials
577 pages
Swanganzparte2 PDF
PDF
No ratings yet
Swanganzparte2 PDF
7 pages
Distribucion 2018 - MEGATIKER
PDF
No ratings yet
Distribucion 2018 - MEGATIKER
36 pages
Differential Forms
From Everand
Differential Forms
Henri Cartan
5/5 (2)
M03 Phys SB Ethy12 0223 U03
PDF
No ratings yet
M03 Phys SB Ethy12 0223 U03
33 pages
008914130
PDF
No ratings yet
008914130
11 pages
Free Time Activities 10-10 TK
PDF
No ratings yet
Free Time Activities 10-10 TK
8 pages
11 2019 Bouagga Takwa
PDF
No ratings yet
11 2019 Bouagga Takwa
1 page
Ford Transmición Automatica Explorer 40 1995-1996 4r44e 4r5
PDF
No ratings yet
Ford Transmición Automatica Explorer 40 1995-1996 4r44e 4r5
1 page
Eheim 2080 Professional 3
PDF
100% (1)
Eheim 2080 Professional 3
18 pages
14 Partial Derivatives 1
PDF
No ratings yet
14 Partial Derivatives 1
24 pages
Lectures on Integral Equations
From Everand
Lectures on Integral Equations
Harold Widom
4.5/5 (2)
Computer Keyboard Layout
PDF
No ratings yet
Computer Keyboard Layout
7 pages
Advanced Soil Mechanics - Braja Das - Consolidacao
PDF
No ratings yet
Advanced Soil Mechanics - Braja Das - Consolidacao
19 pages
Distribucion 2018 - TABLEROS DE ALUMBRADO
PDF
No ratings yet
Distribucion 2018 - TABLEROS DE ALUMBRADO
14 pages
4.citrix Presentation Server4.5
PDF
No ratings yet
4.citrix Presentation Server4.5
285 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
Gard GT8
PDF
No ratings yet
Gard GT8
6 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
Olevel Computer Science Notes 2210
PDF
100% (1)
Olevel Computer Science Notes 2210
20 pages
Artificial Intelligence in Self Organizing Networks
PDF
No ratings yet
Artificial Intelligence in Self Organizing Networks
40 pages
Business Startup Guides-Preparing Yourself Ver 2
PDF
100% (1)
Business Startup Guides-Preparing Yourself Ver 2
4 pages
Exemplos - Equilíbrio de Uma Partícula
PDF
No ratings yet
Exemplos - Equilíbrio de Uma Partícula
8 pages
Копия Workers are losing their chains
PDF
No ratings yet
Копия Workers are losing their chains
1 page
1199 2638 1 SM - Unlocked
PDF
No ratings yet
1199 2638 1 SM - Unlocked
7 pages
VW Transmisión Automática Golf 1997 PDF
PDF
No ratings yet
VW Transmisión Automática Golf 1997 PDF
1 page
Geography - Food From Around The World 53
PDF
No ratings yet
Geography - Food From Around The World 53
1 page
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
JCo Tutorial
PDF
No ratings yet
JCo Tutorial
58 pages
SMR Taludes
PDF
No ratings yet
SMR Taludes
3 pages
Boeco MC 24
PDF
No ratings yet
Boeco MC 24
1 page
Grauer Weil Article Business India
PDF
No ratings yet
Grauer Weil Article Business India
5 pages
Distribucion 2018 - BTPLUG
PDF
No ratings yet
Distribucion 2018 - BTPLUG
4 pages
KRF15
PDF
No ratings yet
KRF15
1 page
Basic Fortigate Firewall Configuration: Content at A Glance
PDF
No ratings yet
Basic Fortigate Firewall Configuration: Content at A Glance
17 pages
FEAP Contact Cmanual
PDF
No ratings yet
FEAP Contact Cmanual
52 pages
Aggregate Impact Value
PDF
No ratings yet
Aggregate Impact Value
3 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
Substitution Method
PDF
No ratings yet
Substitution Method
6 pages
01 - Motion in A Striaght Line Hans Ohanian
PDF
No ratings yet
01 - Motion in A Striaght Line Hans Ohanian
11 pages
Lec 11 Clock Network Design
PDF
No ratings yet
Lec 11 Clock Network Design
61 pages
Bomba Reciprocante Gaso 1800 Duplex Piston Pump
PDF
100% (2)
Bomba Reciprocante Gaso 1800 Duplex Piston Pump
2 pages
Rman CMD
PDF
No ratings yet
Rman CMD
34 pages
String Matching
PDF
100% (1)
String Matching
12 pages
Thermodynamics Onkar Singh
PDF
No ratings yet
Thermodynamics Onkar Singh
18 pages
3 Pipeline
PDF
No ratings yet
3 Pipeline
21 pages
Lecture 5 - Computer-Assisted Audit Tools and Techniques
PDF
100% (1)
Lecture 5 - Computer-Assisted Audit Tools and Techniques
6 pages
Testing Methodology
PDF
No ratings yet
Testing Methodology
6 pages
VW Transmisión Automática Bora Ag4 PDF
PDF
No ratings yet
VW Transmisión Automática Bora Ag4 PDF
1 page
Unit 4 Uncertain Knowledge Complete
PDF
No ratings yet
Unit 4 Uncertain Knowledge Complete
14 pages
LinksMapping (Excel) Internals Readme
PDF
100% (1)
LinksMapping (Excel) Internals Readme
22 pages
Lpc1343 Introduction
PDF
No ratings yet
Lpc1343 Introduction
11 pages
Chapter 5. HTML Forms: Table of Contents
PDF
No ratings yet
Chapter 5. HTML Forms: Table of Contents
36 pages
ARQ
PDF
No ratings yet
ARQ
6 pages
Nethasp
PDF
No ratings yet
Nethasp
24 pages
Graph Traversal Algorithm: Recapitulation
PDF
No ratings yet
Graph Traversal Algorithm: Recapitulation
14 pages
Updating Firmware of SIM808 BT Function
PDF
No ratings yet
Updating Firmware of SIM808 BT Function
9 pages
Matrix Chain Multiplication
PDF
No ratings yet
Matrix Chain Multiplication
11 pages
Advanced C Concepts: 2501ICT Nathan
PDF
No ratings yet
Advanced C Concepts: 2501ICT Nathan
32 pages
Networking Basics
PDF
No ratings yet
Networking Basics
14 pages
706 - Mass Polytechnic College, Kumbakonam Department of Computer Engineering Assignment No: 1
PDF
No ratings yet
706 - Mass Polytechnic College, Kumbakonam Department of Computer Engineering Assignment No: 1
26 pages
Transport Layer Notes Module 3
PDF
No ratings yet
Transport Layer Notes Module 3
10 pages
4 Reg Ex
PDF
No ratings yet
4 Reg Ex
26 pages
MCQ XML
PDF
No ratings yet
MCQ XML
5 pages
Android Seminar Presentation
PDF
No ratings yet
Android Seminar Presentation
23 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
OS and Software
PDF
No ratings yet
OS and Software
16 pages
Strassen
PDF
No ratings yet
Strassen
8 pages
Configuration Management Tools
PDF
No ratings yet
Configuration Management Tools
14 pages
Myhill Nerode
PDF
No ratings yet
Myhill Nerode
10 pages
Auto
PDF
No ratings yet
Auto
7 pages
2nd Class
PDF
No ratings yet
2nd Class
7 pages
Disjoint Set
PDF
No ratings yet
Disjoint Set
4 pages
Student Information Synopsis
PDF
No ratings yet
Student Information Synopsis
7 pages
Pumping Lemma Note - Get - Easy
PDF
No ratings yet
Pumping Lemma Note - Get - Easy
3 pages
Cheat Sheet - Useful CLI Commands 4.0
PDF
No ratings yet
Cheat Sheet - Useful CLI Commands 4.0
3 pages
Agile Software Development - A Gentle Introduction
PDF
No ratings yet
Agile Software Development - A Gentle Introduction
1 page
Calibration Problem Minimum No of Control Points
PDF
No ratings yet
Calibration Problem Minimum No of Control Points
1 page
Client Server OS Model (Part 1)
PDF
No ratings yet
Client Server OS Model (Part 1)
2 pages
LaTeX - List of Notations (Nomenclature) - Simon Silk
PDF
No ratings yet
LaTeX - List of Notations (Nomenclature) - Simon Silk
2 pages
Resume - Arsalan Khan
PDF
No ratings yet
Resume - Arsalan Khan
2 pages
PLC Types
PDF
No ratings yet
PLC Types
2 pages
Aran Khanna: Arankhanna@college - Harvard.edu
PDF
No ratings yet
Aran Khanna: Arankhanna@college - Harvard.edu
1 page
Choto Didi
PDF
No ratings yet
Choto Didi
1 page