[algogeeks] Re: DP equation for interval problem

2013-03-12 Thread Sairam
In the SPOJ , for the given test case, output should be 4 right? The problem is to find the maximum number of overlapping intervals right? If you look at the example it should be 4 rigth? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Re: DP equation for interval problem

2013-02-28 Thread marti
Please reply ...what changes? On Thursday, January 24, 2013 1:35:38 PM UTC+5:30, emmy wrote: please help me with the following problem: http://www.spoj.com/problems/JUICE/ bit mask will require very large memory. If I sort the intervals in decreasing order of their start time.. I still

Re: [algogeeks] Re: DP equation for interval problem

2013-02-28 Thread foram lakhani
in the sorted array, if suppose fr[i].start==fr[i+1].start then u only consider a cut at f[i+1] (that means ith fruit is also cut with the (i+1)th fruit. Thus u keep on incrementing the sorted array until u find sm j s.t. f[j].start!=f[j+1].start Then u check for the condition :

[algogeeks] Re: DP equation for interval problem

2013-02-21 Thread marti
How do i check that condition??? should I include if(f[j].first==f[i].second)match++ ?? On Thursday, January 24, 2013 1:35:38 PM UTC+5:30, emmy wrote: please help me with the following problem: http://www.spoj.com/problems/JUICE/ bit mask will require very large memory. If I sort the

Re: [algogeeks] Re: DP equation for interval problem

2013-02-21 Thread anshu
@ all. what if we use greedy approch..like if we slice when in remaining fruits on screen any one fruit is going to disappear?will it work? On Friday, February 1, 2013 9:07:14 AM UTC+5:30, emmy wrote: Ohk.. I finally got it. Thanks guys!! This was great help. On Mon, Jan 28, 2013 at

[algogeeks] Re: DP equation for interval problem

2013-02-20 Thread marti
? ^^ On Thursday, January 24, 2013 1:35:38 PM UTC+5:30, emmy wrote: please help me with the following problem: http://www.spoj.com/problems/JUICE/ bit mask will require very large memory. If I sort the intervals in decreasing order of their start time.. I still cant make it to a

Re: [algogeeks] Re: DP equation for interval problem

2013-02-20 Thread foram lakhani
did u see the comment that nikhil made herehttp://stackoverflow.com/questions/14545917/spoj-juice-extractor-wrong-ans ? On Thu, Feb 21, 2013 at 1:00 AM, marti amritsa...@gmail.com wrote: ? ^^ On Thursday, January 24, 2013 1:35:38 PM UTC+5:30, emmy wrote: please help me with the

[algogeeks] Re: DP equation for interval problem

2013-02-19 Thread marti
Need help Here is my code: http://shrib.com/fruit On Thursday, January 24, 2013 1:35:38 PM UTC+5:30, emmy wrote: please help me with the following problem: http://www.spoj.com/problems/JUICE/ bit mask will require very large memory. If I sort the intervals in decreasing order of their start

Re: [algogeeks] Re: DP equation for interval problem

2013-01-31 Thread foram lakhani
Ohk.. I finally got it. Thanks guys!! This was great help. On Mon, Jan 28, 2013 at 4:11 PM, Nikhil Karnwal sunnyk12...@gmail.comwrote: no ...when u figure out those m matches just sort them ..now let k=[0,m] if currently u are assuming that kth match is already sliced then all before that k

Re: [algogeeks] Re: DP equation for interval problem

2013-01-29 Thread Nikhil Karnwal
no ...when u figure out those m matches just sort them ..now let k=[0,m] if currently u are assuming that kth match is already sliced then all before that k matches are already sliced.and this u can do by moving incrementally from 0 to mth matches. On Mon, Jan 28, 2013 at 1:43 PM, foram lakhani

Re: [algogeeks] Re: DP equation for interval problem

2013-01-28 Thread foram lakhani
by match u mean that number of fruits that overlap with i th fruit but are not sliced before time i. which means we have to consider 2^m cases where m is the maximum number of fruits that overlap with ith fruit. And this we have to do for each fruit. On Mon, Jan 28, 2013 at 12:54 AM, Nikhil

Re: [algogeeks] Re: DP equation for interval problem

2013-01-28 Thread sunny
NO its not 2^m ,,, you have to use sorting technique .generally we t do such sorting thing in time interval scheduling(standard greedy problem).in case you didn,t understand let me know ... On Monday, January 28, 2013 1:43:35 PM UTC+5:30, emmy wrote: by match u mean that number of

Re: [algogeeks] Re: DP equation for interval problem

2013-01-27 Thread Nikhil Karnwal
Actually dp[i] represent the state in which u make a slice at appearing time of i th fruits.and match represent the overlapping fruits with i. so for each i dp[i]=max(dp[i],dp[j]+match); for all j=[0,i] and match =overlapped fruits with i which are not sliced until the cut of j. Hope this will

[algogeeks] Re: DP equation for interval problem

2013-01-24 Thread sunny
take a structure or pair of start time and finish time and then sort the the structure you know the comparator function the for each for each dp[i] select j belongs to (0,i) and then count the overlap value if(j==0) dp[i]=max(dp[i],match); else

Re: [algogeeks] Re: DP equation for interval problem

2013-01-24 Thread foram lakhani
Thanx for the reply but I didnt get you. What does dp[i] represent ? On Thu, Jan 24, 2013 at 9:50 PM, sunny sharadsin...@gmail.com wrote: take a structure or pair of start time and finish time and then sort the the structure you know the comparator function the for each for each dp[i] select