Re: [algogeeks] Re: Appropriate data structure

2012-07-17 Thread emacs ray
On Wednesday, July 18, 2012 4:26:11 AM UTC+8, Navin Kumar wrote: @Dave sir, K is known in advance. Many people including me think stack as an appropriate data structure but still i am not satisfied with this answer. In case K is not known in advance : according to your solution when a new

[algogeeks] Re: Longest Palindrome

2011-01-07 Thread emacs ray
Manacher's algorithm does. I think it's a variant of Z algorithm. On Dec 31 2010, 5:10 am, Aniket aniket...@gmail.com wrote: How do you find the longest palindrome in a given string in O(n) time? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] Re: How to solve this problem efficiently?

2007-09-05 Thread Ray
. On Sep 5, 10:14 am, Ray [EMAIL PROTECTED] wrote: He has lost many books, since many of his friends borrow his books and never bother to return them. He does not want to lose any more books and has decided to keep a record of all books that he lends to his friends. To make the task

[algogeeks] How to solve this problem efficiently?

2007-09-04 Thread Ray
He has lost many books, since many of his friends borrow his books and never bother to return them. He does not want to lose any more books and has decided to keep a record of all books that he lends to his friends. To make the task of borrowing a book a little difficult, he has given the

[algogeeks] Re: Time complexity

2007-06-12 Thread Ray
I think it's O(n). Because the order of squareroot((log log m) / (log m)) is less than m's. T(n) = a T (n/b) + f(n) 1. O(n ^(lgb/lga) ) O(f(n)) T(n) = O(n ^(lgb/lga)) 2. O(n ^(lgb/lga) ) = O(f(n)) T(n) = O(lg(n)*f(n)) 3. O(n ^(lgb/lga) ) O(f(n)) T(n) = O(f(n)) The problem fits the 1st

[algogeeks] Re: Getting Wronge Answer

2007-06-07 Thread Ray
Hey Minhaz, I have the same algorithm w/z you. #include stdio.h #include algorithm #include memory.h #include string.h #include vector using namespace std; const int MAX_N = 17; int used[MAX_N]; int Prime (int n) { if(n==1) return 0; if(n==2)

[algogeeks] Re: interesting collinear Points problem

2007-05-20 Thread Ray
Hi WangLei, The approach you provide is to compute the angle of every point pairpi, pj, i != j. e.g. the angles are stored in an array. And then find the maxium identical elements of the array. So it's converted to find the Multitude Number: 1. Sort the array 2. traverse the array It runs