Question

U.JUllal llclui SIVETULTUlas The recursive relationship for many functions follows a general pattern. T(n <= 1) = 1 T(n) = a*

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

import math

#inputs
a = int(input("Enter Value for a: "))
b = int(input("Enter Value for b: "))
x = int(input("Enter Value for x: "))
y = int(input("Enter Value for y: "))
n = int(input("Enter Value for n: "))

#recursive function
def T(n):
   if n <= 1:
       return 1
   else:
       return a * T(math.floor(n/b)) + (n**x) * math.ceil(math.log(n)**y)

#answer printing
print("Evaluating " + str(a)+"T(n/" + str(b) +")+n^" + str(x)+ " log2(n)^"+ str(y))
print("T(" + str(n) + ") = " + str(T(n)))

OUTPUT:

Windows PowerShell PS F:\Python\Practice> py .\HomeworkLib1.py Enter Value for a: 1 Enter Value for b: 2 Enter Value for x: 1 Enter

PLEASE MAKE SURE TO LIKE THE ANSWER. THANKS SO MUCH IN ADVANCE :)

Add a comment
Know the answer?
Add Answer to:
U.JUllal llclui SIVETULTUlas The recursive relationship for many functions follows a general pattern. T(n <= 1)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT