Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Text version: Computing the number of combinations of size k of a set of n items C(n, k) = n choose k , where n

image text in transcribed

Text version: Computing the number of combinations of size k of a set of n items C(n, k) = n choose k , where n choose k = n! /(nk)!k! on a computer can be awkward. Computing the numerator and denominator separately and then dividing tends to overflow the integer representation for the intermediate calculations; on the other hand, computing the overall result as the product of floating-point ratios n k n1 k1 . . . nk+1 1 can introduce rounding errors. To get a correct integer answer without over owing, we can use Pascals Formula, which defines the number of combinations using the following recurrence:

C(i, j) = 1 if j = 0 or i = j

C(i 1, j 1) + C(i 1, j) if 1 j i 1

The recurrence is undefined if j > i, or if either i or j is negative. Design and write a dynamic programming algorithm based on the above recurrence that will compute n k given n and

Question 2 (6 marks) Computing the number of combinations of size k of a set of n items C(n, k)(), where on a computer can be awkward. Computing the numerator and denominator separately and then dividing tends to overflow the integer representation for the intermediate calculations; on the other hand, computing the overall result as the product of floating-point ratios 1k+1 can introduce rounding errors To get a correct integer answer without over owing, we can use Pascal's Formula, which defines the number of combinations using the following recurrence: C(i -1,j -1) + C(i-1,j) if 1 Sj Si-1 The recurrence is undefined if j > i, or if either i or j is negative. Design and write a dynamic programming algorithm based on the above recurrence that will compute (?) given n and k

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions