Question

need help in Python programming Learning Objectives You will learn how to create and analyze a...

need help in Python programming

Learning Objectives
You will learn how to create and analyze a recursive algorithm. You will learn about the difference between iterative and recursive algorithms.
Exercise 1: Recursion vs. iteration
a) Create a recursive function that finds the nth element A (n) in the formula A (n) = A (n-1) + 1 / n, A (1) = 1. The function should take the number n as a parameter. This represents series 1 + 1⁄2 + 1/3 + 1⁄4 + ... + 1 / n.
b) Find the recurrence equation for the function from Problem a)
c) Find the running time of the function from task a)
d) Create an iterative function to find the same element as in Problem a) using
dynamic programming.
e) Find the run time of the iterative function in O notation

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

a)

CODE

b)

The recurrence relation is given as:

T(n) = T(n-1) + c where c is a contsant

c)

On solving, we get,

T(n) = O(n)

NOTE: As per Chegg policy, I am allowed to answer specific number of questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
need help in Python programming Learning Objectives You will learn how to create and analyze a...
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