Consider the definition h(0) = 1 h(n) h(n-1)+h(floor(n/2)) + 1 For example, h(2) = h(1) + h(1) + 1 = 3, h(3) = h(2) + h(1) + 1 = 5, etc. An obvious algorithm to compute h is a recursive one, based directly on the defining equations. Is that algorithm efficient? Why or why not? If not, how can the algorithm be improved? Justify your answer.

icon
Related questions
Question
Consider the definition
h(0) = 1
h(n) h(n-1)+h(floor(n/2)) + 1
For example, h(2) = h(1) + h(1) + 1 = 3, h(3) = h(2) + h(1) + 1 = 5, etc. An obvious algorithm to
compute h is a recursive one, based directly on the defining equations. Is that algorithm efficient?
Why or why not? If not, how can the algorithm be improved? Justify your answer.
Transcribed Image Text:Consider the definition h(0) = 1 h(n) h(n-1)+h(floor(n/2)) + 1 For example, h(2) = h(1) + h(1) + 1 = 3, h(3) = h(2) + h(1) + 1 = 5, etc. An obvious algorithm to compute h is a recursive one, based directly on the defining equations. Is that algorithm efficient? Why or why not? If not, how can the algorithm be improved? Justify your answer.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer