[algogeeks] Re: 10 most repeating words

2010-10-22 Thread Vinay...
can u plz elaborate how min heap helps to find most repeating words On Oct 21, 6:40 am, ashish agarwal ashish.cooldude...@gmail.com wrote: use a array of 10 and apply min heap On Thu, Oct 21, 2010 at 7:05 PM, Vinay... vinumars...@gmail.com wrote: how do u find 10 most repeating words on a

[algogeeks] Re: 10 most repeating words

2010-10-22 Thread ligerdave
for a large file, you probably would want to use external sort. kinda like a map-reduce concept. it's actually how sortuniq kinda stuff work in unix/linux when you try to find some TOP X again, we are talking about the memory might not hold the entire file On Oct 21, 9:35 am, Vinay...

Re: [algogeeks] Re: Yahoo coding round question

2010-10-22 Thread Kishen Das
Ok, if you look at the inner loop, it is - for ( j = i to j = 0 ) { sum[j] += A[ i] product[j] *= A [ i] } This is as good as executing - sum[i] = sum [ i ] + A[ i ] --- ( 1 ) sum[i-1]= sum[i-1]+ A[i] ( 2 ) -- --- --- sum[0] = sum[ 0]+A[i] -- ( i )

Re: [algogeeks] Re: Frequent values spoj

2010-10-22 Thread Terence
http://www.informatik.uni-ulm.de/acm/Locals/2007/output/ On 2010-10-21 18:59, ANUJ KUMAR wrote: please give me its output file also so that i can check mine On 10/21/10, ANUJ KUMARkumar.anuj...@gmail.com wrote: thanks On 10/21/10, juver++avpostni...@gmail.com wrote: Please have a look at

Re: [algogeeks] Re: Duplicate in an array

2010-10-22 Thread MOHIT ....
@ dev : i said eariler it work only if max number is less than no of values in array ... -- 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

[algogeeks] how would you find the integer pairs which sum to m in o(n) time complexity

2010-10-22 Thread RIDER
you have an array of n integers, how would you find the integer pairs which sum to m? complexity? if we use hash table then should we implement efficient hash table in c ++? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Re: Adobe question

2010-10-22 Thread MOHIT ....
@rajan array 1 - {2,2} array 2 - { 4,4,1} according 2 you .. unique is {(4+4+1)-(2+2)}=5 ? but it is not... -- 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

Re: [algogeeks] Re: Adobe question

2010-10-22 Thread Saurabh Koar
@Mohit: Rajan clearly sais that array 2 contains all the elements of array1 + 1 extra element..Your example doesn't do so...By the way the method suhhested by Rajan is not universal.It is not necessary that array 2 will contain the same elements as array 1...XOR method will be the best... -- You

[algogeeks] Re: how would you find the integer pairs which sum to m in o(n) time complexity

2010-10-22 Thread juver++
You may use C++ bitset. It requires O(Max / 8) bytes for space. If the array is sorted, there is O(n) solution with O(1) space complexity: keep two pointers, left = 0 and right = n - 1; while (l r) { int diff = A[l] + A[r] - m; if (diff 0) --r; else if (A[l] + A[r] 0) ++l; else break;

[algogeeks] Re: how would you find the integer pairs which sum to m in o(n) time complexity

2010-10-22 Thread Mridul Malpani
if array is not sorted, then how u are solving it in O(n) using bitset. will u plz explain?? On Oct 22, 9:15 pm, juver++ avpostni...@gmail.com wrote: You may use C++ bitset. It requires O(Max / 8) bytes for space. If the array is sorted, there is O(n) solution with O(1) space complexity: keep

[algogeeks] Re: Duplicate in an array

2010-10-22 Thread Mridul Malpani
@ mahesh i didnt get ur algo. why it will work?? plz expalin.. On Oct 20, 3:49 pm, Mahesh_JNU mahesh.jnumc...@gmail.com wrote: Just add the number of the array and let the sum is S. Its complexity is O(n). Now XOR all elements of the array and say the result is X_SUM.Its complexity is  O(n).

[algogeeks] Re: how would you find the integer pairs which sum to m in o(n) time complexity

2010-10-22 Thread juver++
Iterate over an array and add number to the set (simply set up an appropriate bit there). Every time check if there exists in the set number A = m - currentNumber (check corresponding bit in the bitset). So the complexity is O(N). Additional care should be taken for working with negative numbers.

[algogeeks] Re: 10 most repeating words

2010-10-22 Thread Dave
@Ligerdave: Hey, the King James version of the Bible is only about 600,000 words. I use the Bible as an example only because it is a fairly large book. Maybe we are talking 10 megabytes to store the whole thing, seeing that there are some long words such as Maher- shalal-hash-baz, a name that

[algogeeks] DP problem

2010-10-22 Thread Anand
Counting Boolean Parenthesizationshttp://people.csail.mit.edu/bdean/6.046/dp/. You are given a boolean expression consisting of a string of the symbols 'true', 'false', 'and', 'or', and 'xor'. Count the number of ways to parenthesize the expression such that it will evaluate to true. For example,