1 / 15

Subset Sum Problem | Subset Sum Problem Using Dynamic Programming |

This presentation aims to solve the subset sum problems using dynamic programming. This "subset sum problem" tutorial helps learners to learn data structures and algorithms through a standard problem.<br> <br>This presentation will cover the following concepts:<br>1. Introduction<br>2. Problem Statment<br>3. Algorithmic solution<br>4. Implementation

Simplilearn
Télécharger la présentation

Subset Sum Problem | Subset Sum Problem Using Dynamic Programming |

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agenda

  2. Agenda Problem Statement

  3. Click here to watch the video

  4. Agenda Algorithmic solution

  5. Agenda Implementation

  6. Problem Statement

  7. Problem Statement 1 4 2 3 6 8 7 10 2 9 2 2 2 2 2 We will be given a set of non-negative integers, and a value sum, we must determine if there is a subset of the given set with sum equal to given sum.

  8. Algorithmic Solution

  9. Algorithmic Solution We will create a 2D array of size (arr.size() + 1) * (target + 1) of type boolean.

  10. Algorithmic Solution We will create a 2D array of size (arr.size() + 1) * (target + 1) of type boolean. The state DP[i][j] will be true if there exists a subset of elements from A[0….i] with sum value = ‘j’.

  11. Algorithmic Solution We will create a 2D array of size (arr.size() + 1) * (target + 1) of type boolean. The state DP[i][j] will be true if there exists a subset of elements from A[0….i] with sum value = ‘j’. Pseudocode: if (A[i-1] > j) DP[i][j] = DP[i-1][j] else DP[i][j] = DP[i-1][j] OR DP[i-1][j-A[i-1]]

  12. Implementation

More Related