Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

DYNAMIC PROGRAMMING.pptx

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Growth Of IOT NETWORK.pptx
Growth Of IOT NETWORK.pptx
Chargement dans…3
×

Consultez-les par la suite

1 sur 10 Publicité
Publicité

Plus De Contenu Connexe

Plus récents (20)

Publicité

DYNAMIC PROGRAMMING.pptx

  1. 1. NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE, VADAPUTHUPATTI,THENI. DEPARTEMENT OF COMPUTER SCIENCE DYNAMIC PROGRAMMING (The GENERAL METHOD). SUBMITTED BY: S.AISHWARYA LAKSHMI I-MSC(CS)
  2. 2. THE GENERAL METHOD  Dynamic programming approach is similar to divide and conquer in breaking down the problem into smaller and yet smaller possible sub- problems.  But unlike, divide and conquer, these sub-problems are not solved independently.  Rather, results of these smaller sub-problems are remembered and used for similar or overlapping sub-problems.  Dynamic programming is used where we have problems, which can be divided into similar sub-problems, so that their results can be re- used.
  3. 3. THE GENERAL METHOD  Mostly, these algorithms are used for optimization. Before solving the in- hand sub-problem, dynamic algorithm will try to examine the results of the previously solved sub-problems.  The solutions of sub-problems are combined in order to achieve the best solution. So we can say that −  The problem should be able to be divided into smaller overlapping sub- problem.  An optimum solution can be achieved by using an optimum solution of smaller sub-problems.  Dynamic algorithms use Memoization.
  4. 4. Knapsack Problem using Dynamic Programming  Given a set of items, each having different weight and value or profit associated with it.  Find the set of items such that the total weight is less than or equal to a capacity of the knapsack and the total value earned is as large as possible.  The knapsack problem is useful in solving resource allocation problem.  Let X = < x1, x2, x3, . . . . . , xn> be the set of n items. Sets W = <w1, w2, w3, . . . , wn> and V = < v1, v2, v3, . . . , vn> are weight and value associated with each item in X. Knapsack capacity is M unit.
  5. 5. Knapsack Problem using Dynamic Programming  The knapsack problem is to find the set of items which maximizes the profit such that collective weight of selected items does not cross the knapsack capacity.  Select items from X and fill the knapsack such that it would maximize the profit.  Knapsack problem has two variations.  0/1 knapsack, that does not allow breaking of items. Either add an entire item or reject it. It is also known as a binary knapsack.  Fractional knapsack allows breaking of items. Profit will be earned proportionally.
  6. 6. Optimal Merge Patterns  Given n number of sorted files, the task is to find the minimum computations done to reach the Optimal Merge Pattern.  When two or more sorted files are to be merged altogether to form a single file, the minimum computations are done to reach this file are known as Optimal Merge Pattern.
  7. 7. Optimal Merge Patterns  If more than 2 files need to be merged then it can be done in pairs. For example, if need to merge 4 files A, B, C, D.  First Merge A with B to get X1, merge X1 with C to get X2, merge X2 with D to get X3 as the output file.  An optimal merge pattern corresponds to a binary merge tree with minimum weighted external path length.  The function tree algorithm uses the greedy rule to get a two- way merge tree for n files.  The algorithm contains an input list of n trees. There are three field child, rchild, and weight in each node of the tree.  Initially, each tree in a list contains just one node. This external node has lchild and rchild field zero whereas weight is the length of one of the n files to be merged.
  8. 8. Shortest Path  This problem is similar to finding number of path from source to destination with k edges in which we have to find total number of paths.  Now for this problem the shortest path will be one of the total number of paths with lowest weight cost.  To understand this problem, let's take an example of directed graph with 6 vertices {0, 1, 2, 3, 4, 5}, and 9 weighted edges between them.
  9. 9. 0-1 Knapsack  Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack.  In other words, given two integer arrays val[0..n-1] and wt[0..n-1] which represent values and weights associated with n items respectively.  Also given an integer W which represents knapsack capacity, find out the maximum value subset of val[] such that sum of the weights of this subset is smaller than or equal to W.  You cannot break an item, either pick the complete item or don’t pick it .
  10. 10. THANK YOU!!!

×