Recurrence with recursion tree method

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Solving Recurrence with recursion tree method

The image contains two recurrence relations, which can be described as follows:

1. \( T(n) = T(n-1) + 1 \)
2. \( T(n) = T(n-1) + 2 \)

These relations are equations that define a sequence of values where each term is based on the preceding ones. Here, each formula adds a constant to the previous term, illustrating a linear progression. 

There are no graphs or diagrams in the image.
Transcribed Image Text:The image contains two recurrence relations, which can be described as follows: 1. \( T(n) = T(n-1) + 1 \) 2. \( T(n) = T(n-1) + 2 \) These relations are equations that define a sequence of values where each term is based on the preceding ones. Here, each formula adds a constant to the previous term, illustrating a linear progression. There are no graphs or diagrams in the image.
Expert Solution
Step 1

To understand Recurrence Relation lets take the following code in c language:

void Test(int num)

{

if(num>0)

{

printf("%d",num);

Test(num-1);

}

}

In the above code, the recurrence relation tree will be:
Lets input num as 3.

Computer Science homework question answer, step 1, image 1

Here, when the value of num is 3, the algorithm will print the number 3 and call itself with value 3-1=2.

Similarly again the condition num>0 will be true.

So it will again print the current value i.e. 2 and call itself with value 2-1=1.

Since the condition num>0 is true again, then it will print the value 1 and again call itself with value now 1-1=0.

This time the condition num>0 will go false and the code will terminate.

 

So, for input 3, the number of calls made by the funtion will be 4 (Test(3), Test(2), Test(1), Test(0)).

And the number of results printed will be 3 (i.e. 3,2,1)

And for input n, the number of call will be n+1 and the number of times the result will be printed is n.

 

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Recurrence Relation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education