[algogeeks] Re: subset with maximum sum.

2007-10-20 Thread kamalakannan .h
ya thanks vaibhav! this is how i solved the program. actually this was asked in an interview of a company called chronus corp. that person also said the logic so we just traced few arrays and then found the algorithm! On 10/17/07, Vaibhav Jain <[EMAIL PROTECTED]> wrote: > > int sum(int *arr, int n)

[algogeeks] Re: subset with maximum sum.

2007-10-20 Thread kamalakannan .h
On 10/16/07, Muntasir Azam Khan <[EMAIL PROTECTED]> wrote: > > > > h am terrible sorry dude. it is subsequence!!! On Oct 13, 11:39 pm, kannan <[EMAIL PROTECTED]> wrote: > > hellow! > > here is the problem statement. > > you have to find the subset having the maximum sum in the given

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Muntasir Azam Khan
On Oct 17, 7:37 pm, "Channa Bankapur" <[EMAIL PROTECTED]> wrote: > Muntasir, I think I couldn't convey my point to you. When I said terminal > numbers of the subsequence, i didn't mean for the whole array. Lets try to > solve the problem starting with a brute-force algo. > > BruteForce: > Let ar

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Vaibhav Jain
int sum(int *arr, int n) { int i; int max,temp_sum; max=0; temp_sum=0; for(i=0;itemp_sum) temp_sum+=a[i]; else{ max=temp_sum; temp_sum=0; } } return max; } Time complexity= O(n) ##

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Channa Bankapur
Muntasir, I think I couldn't convey my point to you. When I said terminal numbers of the subsequence, i didn't mean for the whole array. Lets try to solve the problem starting with a brute-force algo. BruteForce: Let array be a[0..n-1] sum = 0 for i = 0 to n-1 sumPass = 0 sumCumu = 0 for j =

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Muntasir Azam Khan
On Oct 17, 1:36 pm, "Channa Bankapur" <[EMAIL PROTECTED]> wrote: > Kannan must have meant for "subsequence". Without looking into Kadane's > algo, I was trying to put constraints away from brute-force. > 1. Terminal numbers of the subsequence has to be non-negative. Proof is - if > a terminal nu

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Channa Bankapur
Kannan must have meant for "subsequence". Without looking into Kadane's algo, I was trying to put constraints away from brute-force. 1. Terminal numbers of the subsequence has to be non-negative. Proof is - if a terminal number is negative, just exclude that and you'll get a higher sum. Regards, C

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Muntasir Azam Khan
On Oct 17, 2:31 am, "Vinay Chilakamarri" <[EMAIL PROTECTED]> wrote: > [1,12,-3,14,-6,3,4,-2] > > Check if your approach works here. Apparently not. A subset of an array > should also be continuous, by definition. > > On 10/15/07, Muntasir Azam Khan <[EMAIL PROTECTED]> wrote: > > > > > > > On Oct

[algogeeks] Re: subset with maximum sum.

2007-10-16 Thread Vinay Chilakamarri
[1,12,-3,14,-6,3,4,-2] Check if your approach works here. Apparently not. A subset of an array should also be continuous, by definition. On 10/15/07, Muntasir Azam Khan <[EMAIL PROTECTED]> wrote: > > > > > On Oct 13, 11:39 pm, kannan <[EMAIL PROTECTED]> wrote: > > hellow! > > here is the

[algogeeks] Re: subset with maximum sum.

2007-10-15 Thread Muntasir Azam Khan
On Oct 13, 11:39 pm, kannan <[EMAIL PROTECTED]> wrote: > hellow! > here is the problem statement. > you have to find the subset having the maximum sum in the given array > of +ve and -ve numbers. > try not to follow brute force method. I'm not sure if I'm understanding the question cor

[algogeeks] Re: subset with maximum sum.

2007-10-13 Thread nima aghdaie
read Kadane's Algo. On 10/13/07, kannan <[EMAIL PROTECTED]> wrote: > > > hellow! > here is the problem statement. > you have to find the subset having the maximum sum in the given array > of +ve and -ve numbers. > try not to foll