take another matrix of same size, calculate sum at each element if a[][] is the matrix,SM[][] stores sum till that point SM[0,i] = a[0][i] SM[i,0] = a[i][0] SM[i][j] = SM[i][j-1]+SM[i-1][j]-SM[i-1][j-1]+a[i][j]; i,j=1 to n-1 track max value as u does this.
surender On Sat, Sep 17, 2011 at 6:58 PM, prasanth n <[email protected]> wrote: > @ aditya kumar: > > can you give the algorithm about how to get the sub matrix?? i know how to > get the max sum from an array..but how to do it to find the sub matrix with > max sum?? > > > On Sat, Sep 17, 2011 at 5:07 PM, aditya kumar < > [email protected]> wrote: > >> i guess kadane's algo doesnt tell u abt the subarray element instead it >> tells abt max sum of subarray . to get the element of subarray store the >> end_offset whenever your max_sum changes . >> >> >> On Sat, Sep 17, 2011 at 4:47 PM, sukran dhawan <[email protected]>wrote: >> >>> kadane s algo >>> >>> >>> On Sat, Sep 17, 2011 at 3:25 PM, prasanth n <[email protected]>wrote: >>> >>>> given a matrix with +ve and -ve numbers, find the submatrix with maximum >>>> sum?? >>>> >>>> -- >>>> *prasanth* >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > *prasanth* > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
