Recurrence with recursion tree method
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F153bfb9c-b05e-4b91-94e3-9e151aaf7f28%2F78e7b884-7abe-461b-bb75-abd4f2544416%2F91h8m1p_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
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.
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
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)