Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For each of the following program fragments, give an analysis of the running time and recurrence relation. def fun 1 ( x , y )

For each of the following program fragments, give an analysis of the running time and recurrence relation.
def fun1(x, y) :
if (x ==0) :
return y
else :
return fun1(x -1, x + y)
def fun1(n):
if(n ==1):
return 0
else:
return 1+ fun1(n//2)
def fun1(n):
i =0
if (n >1):
fun1(n -1)
for i in range(n):
print("*",end="")
def fun( a, n):
if(n ==1):
return a[0]
else:
x = fun(a, n -1)
if(x > a[n -1]):
return x
else:
return a[n -1]
def fun(a, b):
if (b ==0):
return 1
if (b %2==0):
return fun(a*a, b//2)
return fun(a*a, b//2)*a
def fun(n):
if(n >0):
fun(n -1)
print(n, end="")
fun(n -1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions