[algogeeks] Integer partition problem - DP

2014-03-01 Thread kumar raja
Given an integer how many number of ways u can partition the number? e.g. 3 can be written as 3,1+2,1+1+1 and 4 can be written as 4, 1+1+1+1,2+2,1+3,1+1+2 So for 3 -- 3 for 4 --5. The order of the elements in the partition does not matter. So how to calculate the number of ways to

Re: [algogeeks] Integer partition problem - DP

2014-03-01 Thread atul anand
Problem is similar to coin change problem(i.e given an array of coins denomination , Find number of ways to create N Rupees).So given input K...fill up array from 1 to K.and use this array and a input to coin change problem On Sat, Mar 1, 2014 at 9:55 PM, kumar raja rajkumar.cs...@gmail.com

Re: [algogeeks] Integer partition problem - DP

2014-03-01 Thread Shashwat Anand
Let us assume you have sum S. The possible numbers it is made up are { 1, 2, .., S }. Now, for every number belonging to the set, you have two options. 1. Subtract currently chosen number from the given set to sum. 2. Choose next number. The state will be defined as (num, sum), where num is the