Re: [algogeeks] Sum of the Sequence

2009-11-06 Thread nikhil garg
Thanks a ton. I found finite calculus very interesting and useful ! On Fri, Nov 6, 2009 at 11:35 AM, abhijith reddy abhijith200...@gmail.comwrote: Thank you so much ! :) On Fri, Nov 6, 2009 at 11:00 AM, Prunthaban Kanthakumar pruntha...@gmail.com wrote: On a related note, The solution I

Re: [algogeeks] Re: aai + bj + ck =0

2009-11-01 Thread nikhil garg
It is clearly O(n^2) . However i am sure there must be better methods available then this semi-naive method. Once i saw a problem which was on 4 lists and not three like here. So same algorithm on that case delievers O(n^3) and was giving me TLE. So yes , we should be able to do it nlogn somehow.

Re: [algogeeks] Re: Identify The f(x) :you are given a series of numbers(asked by MICROSOFT )?

2009-10-31 Thread nikhil garg
This is a very common problem actually. And is most often solved using curve fitting only. We choose the curve to be polynomial of minimum degree and then use some interpolation method to get the exact polynomial. You may like to see the same problem at spoj: https://www.spoj.pl/problems/CMPLS/

[algogeeks] Re: Identify The f(x) :you are given a series of numbers(asked by MICROSOFT )?

2009-10-30 Thread nikhil garg
Check google for Newton's interpolation method. That should help. cheers - nikhil On Fri, Oct 30, 2009 at 10:02 AM, Shiqing Shen ssq...@gmail.com wrote: match the sequence exactly? how to get that polynomial function, i am curious 2009/10/29, Vladimir Reshetnikov v.reshetni...@gmail.com:

[algogeeks] Re: Pouring Water Problem

2009-10-26 Thread nikhil garg
for this . On Mon, Oct 26, 2009 at 12:06 PM, nikhil garg nikhilgar...@gmail.comwrote: We at any one step can measure only 3 quantities: A liters , B liters , or (A-B) litres. ( assuming AB) With every operation we have a cost associated: For A liter , we need 2 operations( Fill A , transfer from

[algogeeks] Re: find the index of a number in a sorted array

2009-10-26 Thread nikhil garg
probably the only entirey different approach ( except small variations in Bsearch ) is use of Hashing ( or for that matter , HashMaps ) On Sun, Oct 25, 2009 at 1:36 PM, harit agarwal agarwalha...@gmail.comwrote: the only other way can be the jump exponentially during search as in binary search

[algogeeks] Re: Pouring Water Problem

2009-10-26 Thread nikhil garg
We at any one step can measure only 3 quantities: A liters , B liters , or (A-B) litres. ( assuming AB) With every operation we have a cost associated: For A liter , we need 2 operations( Fill A , transfer from A to vessel) . For B liter , similarly we need 2 operations And for (A-B) litres we

[algogeeks] Re: n balls and k different colors 1=k=n

2009-10-10 Thread nikhil garg
a very simple proof of the formula is using generating function for counting On Sat, Oct 10, 2009 at 3:08 PM, Prunthaban Kanthakumar pruntha...@gmail.com wrote: I just noticed that in your problem the balls are 'similar'. Then the solution is a simple composition and the answer is {n-1, k-1}

[algogeeks] Re: sum of subsequence.

2009-10-09 Thread nikhil garg
This is a simple dp problem . define for each i following 2 quantities : best1[i] : best sum in similar constraint of first i elements only when last ( ith ) term is always included best2[i] : best sum in similar constraint of the first i elements only when last (ith ) term is NOT included so we