[algogeeks] Microsoft interview question

2010-12-12 Thread ebrima saye
I can only think of one way off the top of my head: class IndexedDocument { HashTableString, int index; String contents; /// Build an index of words and their position in the document void buildIndex() { for each word in document { add word, position to index

Re: [algogeeks] help me reduce the time limit

2010-12-12 Thread Amir hossein Shahriari
use segment tree http://en.wikipedia.org/wiki/Segment_tree -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: Microsoft interview question

2010-12-12 Thread Amir hossein Shahriari
use suffix tree it's much faster than simple trie with ukkonen's method you can build it in O(size of document) and then searching in it is practically O(1) http://en.wikipedia.org/wiki/Suffix_tree http://www.cs.helsinki.fi/u/ukkonen/SuffixT1withFigs.pdf On Fri, Dec 10, 2010 at 7:54 PM, ADITYA

Re: [algogeeks] just confirming my answer

2010-12-12 Thread Terence
I think the answer is (2^m)^(2^n) (or 2^(m*2^n)) For m=1, the answer is 2^2^n. We can express the function using a truth table with 2^n entries, one entry for each possible input set. And each entry has (n+m) fields, represent the n inputs and m outputs. The m*2^n output fields can be filled

Re: [algogeeks] Longest interval with maximum sum

2010-12-12 Thread Amir hossein Shahriari
each value in A and B is 0 or 1 so the sum of all elements in A (or B) is n so the sum of all elements in C which is the sum of differences between values in A and B is between -n and n now we want to maximize j-i for which C[i]+C[i+1]+...+C[j] = 0 suppose that sum(i) = C[1]+C[2]+...+C[i] which is

Re: [algogeeks] Valid Array

2010-12-12 Thread Terence
No. You made the same mistake as I. Try this case: {1, 2, 2, 5, 5}. Actually, this case defeats the solution of Manmeet's, yours, and mine. (same min/max, same sum, same xor result) I think the key point is that the N variable cannot be determined by 1 or 2 equation constraint. On 2010-12-10

[algogeeks] Call for Papers Sessions: The 2011 International Conference on Foundations of Computer Science (FCS'11), USA, July 18-21, 2011

2010-12-12 Thread A. M. G. Solo
   CALL  FOR  PAPERS and   Call For Workshop/Session Proposals       FCS'11    The 2011 International Conference on Foundations of Computer Science      Date and Location: July

Re: [algogeeks] Longest interval with maximum sum

2010-12-12 Thread ADITYA KUMAR
@amir nice solution On Sun, Dec 12, 2010 at 11:40 AM, Amir hossein Shahriari amir.hossein.shahri...@gmail.com wrote: each value in A and B is 0 or 1 so the sum of all elements in A (or B) is n so the sum of all elements in C which is the sum of differences between values in A and B is

[algogeeks] programming puzzles

2010-12-12 Thread awesomeandroid
visit this blog http://code-forum.blogspot.com/ and http://coders-stop.blogspot.com/ for programming puzzles. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from

[algogeeks] Find small strings in big string

2010-12-12 Thread Prims
Given that you have one string of length N and M small strings of length L . How do you efficiently find the occurrence of each small string in the larger one I heard the best solution for this problem is to use generalized suffix tree. Can any one explain the solution for this problem in detail

[algogeeks] Re: Find small strings in big string

2010-12-12 Thread awesomeandroid
KMP and RabinKarp On Dec 12, 7:07 pm, Prims topcode...@gmail.com wrote: Given that you have one string of length N and M small strings of length L . How do you efficiently find the occurrence of each small string in the larger one I heard the best solution for this problem is to use

Re: [algogeeks] Re: find the number.

2010-12-12 Thread shoban babu
@Dave :but it will take more time. any other solution O(n^2).? On Sat, Dec 11, 2010 at 7:48 PM, Dave dave_and_da...@juno.com wrote: @Naresh: The sequence of numbers generated by this rule for any given starting number is called a Collatz Sequence. Try googling it. Here is a list of the

Re: [algogeeks] Re: solve these puzzles.....very very urgent......thnx in advance

2010-12-12 Thread ADITYA KUMAR
ans for 1st one is 24 On Sat, Nov 27, 2010 at 3:12 PM, vamsi achyuth vamsiachy...@gmail.comwrote: these were the problems asked in tcs written exam. On 27 November 2010 15:08, srinivas reddy srinivaseev...@gmail.comwrote: @youngboy you have to choose one value for variable only

Re: [algogeeks] Re: The best multiply matrix algorithms ?

2010-12-12 Thread Rakib Ansary Saikot
It is NOT possible to multiply two matrices in less than O(n^2) simply because there are n^2 elements, and you got to touch all of them at least once! Rakib On 12/10/10, Luciano Junior luciano@gmail.com wrote: Dave, thank You very much for yours information. Really, I want to know a

Re: [algogeeks] Re: Find small strings in big string

2010-12-12 Thread mohit ranjan
@awesomeandroid how you will use KMP in ths case, can you plz explain ? Mohit On Sun, Dec 12, 2010 at 8:01 PM, awesomeandroid priyaranjan@gmail.comwrote: KMP and RabinKarp On Dec 12, 7:07 pm, Prims topcode...@gmail.com wrote: Given that you have one string of length N and

[algogeeks] file handling

2010-12-12 Thread neeraj agarwal
i am facing problem in file handling in C can any one suggest me how to implement them. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email