Question: Problem 1 : Recursion and Tail Recursion In class for the second lecture we practiced recursion on this fuction: ( 0 n 0 2 n

Problem 1: Recursion and Tail Recursion
In class for the second lecture we practiced recursion on this fuction:
(0n02n+h(n1)+h(n2) o.w.
(1)
(2)
h(n)=
If we tried our first technique to implement tail recursion, wed have this:
htr(n, acc0, acc1) The first ten values are:
1h(0)=1;htr(0)=1
2h(1)=4;htr(1)=4
3h(2)=9;htr(2)=9
4h(3)=19; htr(3)=19
5h(4)=36; htr(4)=40
6h(5)=65; htr(5)=79
7h(6)=113; htr(6)=153
8h(7)=192; htr(7)=288
9h(8)=321; htr(8)=533
10h(9)=531; htr(9)=971
=
(
[acc0, acc1][n]
htr(n 1, acc1,2n + acc0+ acc1)
n 2 o.w.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!