Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a recursive function called permuteR ( string , position ) that returns each reordering of the letters in a string. def swap ( s

Consider a recursive function called permuteR (string, position) that returns each reordering of the letters in a string.
def swap(st,1,r) :
st = list(st)
st 1,st [r]=st[r], st[1]
return ''.join(st)
def permuteR(st,l=0 :
if len(st)==1 :
return [st]
L=[]
for i in range(1, len(st)):
st =swap(st,i,l)
L += permuteR(st, l+1)
st =swap(st,i,1)
return L
print(permuteR("123"))
# ['123','132','213','231','321','312']
What is the recurrence relation of pe rmuteR?
T(n)=K+(n-1)**T(n-1)
T(n)=K+T(n-1)
T(n)=K+T(nlog(n))
T(n)=K+T((n+1)log(n))
image text in transcribed

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

Managing Variability within a Supply Chain Network

Answered: 1 week ago

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago