Download presentation

Presentation is loading. Please wait.

Published byColleen Phillips Modified over 3 years ago

1
Algorithm Design 3

2
We have seen two different approaches to computing the number of combinations of m out of n items C(n,m) or n choose m. Divide-and-Conquer is clearly inferior to Dynamic Programming since the latter requires the computation of each sub-instance only once. Is there a better approach? In terms of computational load In terms of range of values For example what is the value of C(100,000, 99,998) and can this value be computed using either method described? (D&C or DynPro). If yes, what is the order of complexity? If asked to compute this value by hand, how would you proceed? Introduction

3
Developing a Better Algorithm You have seen two methods for computing binomial coefficients based on a recurrence relation. Using the closed form expression for binomial coefficients provided in the textbook create another version of this function that has a lower order of complexity than either bin or bin2. Develop, implement and test your version of this function and then derive its order of complexty. Hint: simplify the factorial terms algebraically and capture their essential computations in a single loop.

4
Another Binary Coefficient Function function bin3(n,k:integer)return long_float is val : long_float:=1.0; numdone: boolean:=false; dendone: boolean:=false; numval : integer; denval : integer; numend : integer; begin numval:=n; if (n-k)>k then numend:=n-k+1; denval:=k; else numend:=k+1; denval:=n-k; end if; if n>k and k>0 then while not(numdone and dendone) loop if (val<1.0 and not(numdone)) or dendone then val:=val*long_float(numval); numval:=numval-1; numdone:=(numval

5
Summary Divide-and-Conquer method of computing combinations is impractical. Dynamic Programming is also limited. Sometimes the direct calculation or brute-force approach is preferred. The range of values in the direct calculation method is limited only by the size of the answer.

Similar presentations

OK

1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.

1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Vector scan display ppt online Ppt on galaxy grand Ppt on power system harmonics study Ppt on sports day logo Ppt on networking related topics about psychology Ppt on leverages definition Ppt on solar system and stars Ppt on social work in india Ppt on 60 years of indian parliament today Ppt on mobile number portability in india