Question: Python assignment. 1. Use the fact that S(0,0)=1, S(0,x)=S(x,0)=0 if x is not 0, and S(n,k) = kS(n-1,k)+S(n-1,k-1) to write a recursive function S() which

Python assignment.

1. Use the fact that S(0,0)=1, S(0,x)=S(x,0)=0 if x is not 0, and S(n,k) = kS(n-1,k)+S(n-1,k-1) to write a recursive function S() which computes the sterling numbers.

>>> S(9,4) 7770

Note that P{n,k} = 0 if either n or k is less than one, except for when they are both zero, in which case it equals 1. Use this fact together with the recurrence relation P{n,k} = P{n-k,k}+P{n-1,k-1} to write a recursive function P() which computers the number of partitions of n in to k nonempty parts.

>>> P(9,4) 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!