[algogeeks] Re: Stortest Subtext Problem

2008-02-14 Thread Andrey
Yes! Look here there is a program: http://groups.google.com/group/algogeeks/browse_thread/thread/11b032a28995baed/7b896ee015b090e5 On Feb 13, 3:16 am, conundrum [EMAIL PROTECTED] wrote: Given a text and a set of keywords, is there a linear time algorithm to find the smallest subtext containing

[algogeeks] Re: Algo.. phone book

2007-11-10 Thread Andrey
just store list of phone number as leaf in trie. What abt collisions in Trie?? Like if same name then??? Still don't understand why you all so eager to use Trie, in my point of view this is improper data structure in this case. --~--~-~--~~~---~--~~ You

[algogeeks] Re: Discussion on unique-elements-in-an-array

2007-11-10 Thread Andrey
and to make a heap out of it we need O(n) space. heap sort will surely take constant amount of auxially space if heap is already build. isn't it? correct me if i m wrong.. On 11/9/07, Andrey [EMAIL PROTECTED] wrote: Heapsorthttp://en.wikipedia.org/wiki/Heapsort

[algogeeks] Re: Algo.. phone book

2007-11-09 Thread Andrey
I thought about trie first but then I've change my mind and decided that I'd rater use a simple binary tree or even an sorted array. As we have quite limited set of first names and surnames we can easily index them i.e. store them in sorted array and use an index in the array indead of the

[algogeeks] Re: Discussion on unique-elements-in-an-array

2007-11-09 Thread Andrey
Heapsort http://en.wikipedia.org/wiki/Heapsort#Comparison_with_other_sorts On Nov 9, 3:54 pm, Pramod Negi [EMAIL PROTECTED] wrote: which algo sort array in O(N lgN) without extra space?? On 11/6/07, Andrey [EMAIL PROTECTED] wrote: dor is absolutely right O(N*log(N

[algogeeks] Re: Algo.. phone book

2007-11-09 Thread Andrey
No reasons, the structure is static so sorted array is the fastest way. Don't know how about trie, it's hard to estimate... On 9 нояб, 18:16, Ajinkya Kale [EMAIL PROTECTED] wrote: How about using a Red-Black tree ? On 11/9/07, Andrey [EMAIL PROTECTED] wrote: I thought about trie

[algogeeks] Re: Finding the n integers given the set of sums.

2007-11-08 Thread Andrey
and then 4,5,6,7 at the right side. Look at the solutions. How they differ? Is this natural? Though the order is not imp you cant tell which 2 variables for a particular equation. On Nov 7, 6:55 pm, Andrey [EMAIL PROTECTED] wrote: Won't work. You just can't build such a system, because

[algogeeks] Re: Finding the n integers given the set of sums.

2007-11-07 Thread Andrey
matrix. Inverting the matrix can let you solve the problem for many instances. It would be interesting to exploit the special structure of this matrix in order to speed up the computation. Please post if you find such an improvement. Best Regards, Antonio On Nov 7, 5:16 pm, Andrey [EMAIL

[algogeeks] Finding the n integers given the set of sums.

2007-11-07 Thread Andrey
Any set of n integers form n(n 1)/2 sums by adding every possible pair. The task is to find the n integers given the set of sums. Any ideas? I've found out the solution but I doubt it the best one... --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] Finding the n integers given the set of sums.

2007-11-07 Thread Andrey
Any set of n integers form n(n - 1)/2 sums by adding every possible pair. The task is to find the n integers given the set of sums. Any ideas? I've found out the solution but I doubt it the best one... --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] Re: Discussion on unique-elements-in-an-array

2007-11-06 Thread Andrey
dor is absolutely right O(N*log(N)) is straightforward.. sort the array in O(N*log(N)) and then remove duplicates in linear time. it doesn't need any extra memory. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-12 Thread Andrey
You'd better wite a program. On 11 окт, 10:42, Vaibhav Jain [EMAIL PROTECTED] wrote: Algo: 1. initialize final_result array with whole sequence and count number of keywords in no_of_keys and initialize counter array for keywords with value zero. 2. if sequence_ptr is not null then start

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-12 Thread Andrey
You'd better write a program. On Oct 11, 10:42 am, Vaibhav Jain [EMAIL PROTECTED] wrote: Algo: 1. initialize final_result array with whole sequence and count number of keywords in no_of_keys and initialize counter array for keywords with value zero. 2. if sequence_ptr is not null then

[algogeeks] Re: NxN matrix of positive and negetive integers?

2007-10-12 Thread Andrey
I doubt It will be O(n^3).. Dynamic programming algorithm, by size of submatrix, will give at least O(N ^ 4), won't it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] Re: NxN matrix of positive and negetive integers?

2007-10-12 Thread Andrey
Does anyone knew more effective solution then DP? On Oct 12, 3:46 pm, Andrey [EMAIL PROTECTED] wrote: I doubt It will be O(n^3).. Dynamic programming algorithm, by size of submatrix, will give at least O(N ^ 4), won't it? --~--~-~--~~~---~--~~ You received

[algogeeks] Re: NxN matrix of positive and negetive integers?

2007-10-12 Thread Andrey
of arr[a][c], arr[a+1][c], ... arr[b-1][c] handy ( i.e. in O(1) algo). But that's fine, we can precalc them using prefix-sum (O(n^2)). Look at my post inwww.algorithmist.com... search for UVa problem 108 - Maximum Sum. Good luck. On 10/12/07, Andrey [EMAIL PROTECTED] wrote: Does anyone

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-10 Thread Andrey
No, I am not trying to do that at all. The trie is built to contain only keywords. It can then be used to answer the question for the current character 'Is this character part of a candidate keyword?' and do this O(1). Candidate keywords are identified initially by the trei root returning a

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-10 Thread Andrey
No, I am not trying to do that at all. The trie is built to contain only keywords. It can then be used to answer the question for the current character 'Is this character part of a candidate keyword?' and do this O(1). Candidate keywords are identified initially by the trei root returning a

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-08 Thread Andrey
I have to admit that I was wrong in my previous post. I stated that if we have all words in the enumerated we can operate with them better (faster) but it is true. Enumeraing of the words makes no sence.. Similar objections to using a hash table to assign integers to words. If collisions are

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-01 Thread Andrey
(N + M) + N + M So if we don't have all word already enumerated you are right. On Oct 1, 4:10 am, Andrey [EMAIL PROTECTED] wrote: Check this program: #include map #include string #include iostream #include algorithm #include iterator using namespace std; class Range : public

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-09-30 Thread Andrey
Check this program: #include map #include string #include iostream #include algorithm #include iterator using namespace std; class Range : public pairconst char*, const char* { public: size_t size() const { return second - first; } Range(const char* f=0, const char * s=0)