Re: [algogeeks] data structures for text editor
http://en.wikipedia.org/wiki/Rope_%28computer_science%29 On Sun, Jan 15, 2012 at 7:26 AM, Umer Farooq the.um...@gmail.com wrote: Are the number of words in one line fixed? On Sun, Jan 15, 2012 at 1:10 AM, uttam tiwari utmbhu...@gmail.com wrote: what are the data structures that should be used to make a text editor where we can perform following tasks: 1. insert text 2. search text 3. delete text 4. automatic line change(not mandatory) 5. undo n redo 6.cursor movement(left or right shift) i need data structures only, kindly reply... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Umer -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: data structures for text editor
check rope for wiki . Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/HXhD39wH1D0J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: rectangle of max sum MS Q
this problem is solved in O( n^3). 2012/1/16 jaimedp jaim...@gmail.com Compute the integral matrix, find the min and max in that matrix (given that min is left and up from the max) and those would be the top left and bottom right of the max sum matrix. mmm, I think that works On Jan 15, 7:25 pm, Ashish Goel ashg...@gmail.com wrote: given a m*n matrix, find the subset rectangle with max sum (any other rectangle taken would have lesser sum) Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] rectangle of max sum MS Q
find cumulative sum of each column. now for each arr[x][y] = sum of arr[i=0 to x] [j] ; a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3 a4 d4 c4 d4 now we have reduced this problem to find max-subarray . which can be efficiently calculated using kadane's algo for each row. NOTE: now suppose if row = 0 does not participate in calculating max sum matrix so u need to subtract a1 from a2,a3,a4 similarly for other element in row 1,2,3. now updated matrix considered i.e from (row =1 to row =3 ). for this updated matrix, each[x][y] is the sum of arr[i=1 to x] [j]. similarly do for other elements. On Mon, Jan 16, 2012 at 6:55 AM, Ashish Goel ashg...@gmail.com wrote: given a m*n matrix, find the subset rectangle with max sum (any other rectangle taken would have lesser sum) Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: rectangle of max sum MS Q
You're right, that wouldn't work... On Jan 16, 9:26 am, Adolfo Ccanto adol...@gmail.com wrote: this problem is solved in O( n^3). 2012/1/16 jaimedp jaim...@gmail.com Compute the integral matrix, find the min and max in that matrix (given that min is left and up from the max) and those would be the top left and bottom right of the max sum matrix. mmm, I think that works On Jan 15, 7:25 pm, Ashish Goel ashg...@gmail.com wrote: given a m*n matrix, find the subset rectangle with max sum (any other rectangle taken would have lesser sum) Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] rectangle of max sum MS Q
what about taking sum of the boundaries of the rectangle and omiting the boundary with least sum and including the rest of rectangle in the sub-set? On Mon, Jan 16, 2012 at 8:51 PM, atul anand atul.87fri...@gmail.com wrote: find cumulative sum of each column. now for each arr[x][y] = sum of arr[i=0 to x] [j] ; a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3 a4 d4 c4 d4 now we have reduced this problem to find max-subarray . which can be efficiently calculated using kadane's algo for each row. NOTE: now suppose if row = 0 does not participate in calculating max sum matrix so u need to subtract a1 from a2,a3,a4 similarly for other element in row 1,2,3. now updated matrix considered i.e from (row =1 to row =3 ). for this updated matrix, each[x][y] is the sum of arr[i=1 to x] [j]. similarly do for other elements. On Mon, Jan 16, 2012 at 6:55 AM, Ashish Goel ashg...@gmail.com wrote: given a m*n matrix, find the subset rectangle with max sum (any other rectangle taken would have lesser sum) Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Umer -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: rectangle of max sum MS Q
@all it was said subset rectangle with max sum. since every square is also a rectangle for m*n take the square matrix of n*n (nm) only m -n +1 options will have to comareuse backtracking to compare the next column's sum to present it will take O(n) time using backtracking.. please correct it if anuthing wrong is dere -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] algo qstn
An ant moves on a regular grid of squares that are coloured either black or white. The ant is always oriented in one of the cardinal directions (left, right, up or down) and moves from square to adjacent square according to the following rules: - if it is on a black square, it flips the color of the square to white, rotates 90 degrees counterclockwise and moves forward one square. - if it is on a white square, it flips the color of the square to black, rotates 90 degrees clockwise and moves forward one square. Starting with a grid that is entirely white, how many squares are black after 1018 moves of the ant? source http://projecteuler.net/problem=349 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: rectangle of max sum MS Q
I have an approach to solve this question my approach is basesd on given question and it's solution so first of all understand this question and it's solution http://www.spoj.pl/problems/HISTOGRA/ http://www.ideone.com/lfORK I know I may not able to expplain properly but if you read it twice or thrice with some feeling what's happening and how the two problem solutions are linked to each other then you may get the answer. Now for your matrix a[n][m] do this first create another matrix s[n][m] where s[i][j] = a[i][j] + a[i][j+1] + .. .+a[i][m-1] s[i][j] = 0 if(a[i][j] = 0) now supposw for matrix a[4][4] 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 your s[n][m] will be 3 2 1 0 0 3 2 1 0 3 2 1 2 1 0 1 for(all columns 0 to 3 ) { consider rectangular bars are there with height s[i][j] where i will be from 0 to n - 1 j = column number which is fixed for each iteration. then find solution using above algorithm and keep track of maximum area } then maximum area which you will get will give you solution -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: rectangle of max sum MS Q
@UTKARSH : my approach is similar to yours written above. but does your algo taking into account the following conditions:- 1 0 0 0 0 1 1 -2 0 1 1 -2 1 1 0 1 here highlighted triangle is the max square . but i guess you are not considering this condition . correct me if i am wrong. On Tue, Jan 17, 2012 at 12:46 AM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: I have an approach to solve this question my approach is basesd on given question and it's solution so first of all understand this question and it's solution http://www.spoj.pl/problems/HISTOGRA/ http://www.ideone.com/lfORK I know I may not able to expplain properly but if you read it twice or thrice with some feeling what's happening and how the two problem solutions are linked to each other then you may get the answer. Now for your matrix a[n][m] do this first create another matrix s[n][m] where s[i][j] = a[i][j] + a[i][j+1] + .. .+a[i][m-1] s[i][j] = 0 if(a[i][j] = 0) now supposw for matrix a[4][4] 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 your s[n][m] will be 3 2 1 0 0 3 2 1 0 3 2 1 2 1 0 1 for(all columns 0 to 3 ) { consider rectangular bars are there with height s[i][j] where i will be from 0 to n - 1 j = column number which is fixed for each iteration. then find solution using above algorithm and keep track of maximum area } then maximum area which you will get will give you solution -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] c output
#includestdio.h int main() { double p=fabs(24.9996); double t=fabs(25.0003); printf(%0.3lf %0.3lf\n,p,t); if(fabs(p)==fabs(t)) printf(equal);// why this not executed? } why the equal not printed in this code...? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
printf(%0.3lf %0.3lf\n,p,t); its just printing at your convenience . you are not changing the value of p,t . change this statement to printf(%0.5lf %0.5lf\n,p,t); On Tue, Jan 17, 2012 at 11:27 AM, dabbcomputers dabbcomput...@gmail.comwrote: #includestdio.h int main() { double p=fabs(24.9996); double t=fabs(25.0003); printf(%0.3lf %0.3lf\n,p,t); if(fabs(p)==fabs(t)) printf(equal);// why this not executed? } why the equal not printed in this code...? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
atul he is assigning the value later on. i think format specifier . rounds up the number in last decimal place. On Tue, Jan 17, 2012 at 11:53 AM, atul anand atul.87fri...@gmail.comwrote: printf(%0.3lf %0.3lf\n,p,t); its just printing at your convenience . you are not changing the value of p,t . change this statement to printf(%0.5lf %0.5lf\n,p,t); On Tue, Jan 17, 2012 at 11:27 AM, dabbcomputers dabbcomput...@gmail.comwrote: #includestdio.h int main() { double p=fabs(24.9996); double t=fabs(25.0003); printf(%0.3lf %0.3lf\n,p,t); if(fabs(p)==fabs(t)) printf(equal);// why this not executed? } why the equal not printed in this code...? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
It's not a good way to compare two floats directly using =, try something like below: http://ideone.com/c65Vl -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
i gues atul is crkt. its jst printin by user convenience...when actually d two are not equal... i guess the code...xplains well...dats y equal is not printed..out #includestdio.hint main(){ double p=fabs(24.9996); printf(%lf\n,p); double t=fabs(25.0003); printf(%lf\n,t); printf(%0.3lf %0.3lf\n,p,t); printf(%lf\n%lf\n,fabs(p),fabs(t)); if(fabs(p)==fabs(t)) printf(equal);// why this not executed?} crkt me if i'm wrong.. Regards, PAYAL GUPTA, NIT-BHOPAL.. On Tue, Jan 17, 2012 at 12:13 PM, shady sinv...@gmail.com wrote: atul he is assigning the value later on. i think format specifier . rounds up the number in last decimal place. On Tue, Jan 17, 2012 at 11:53 AM, atul anand atul.87fri...@gmail.comwrote: printf(%0.3lf %0.3lf\n,p,t); its just printing at your convenience . you are not changing the value of p,t . change this statement to printf(%0.5lf %0.5lf\n,p,t); On Tue, Jan 17, 2012 at 11:27 AM, dabbcomputers dabbcomput...@gmail.comwrote: #includestdio.h int main() { double p=fabs(24.9996); double t=fabs(25.0003); printf(%0.3lf %0.3lf\n,p,t); if(fabs(p)==fabs(t)) printf(equal);// why this not executed? } why the equal not printed in this code...? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.