[algogeeks] Re: Pouring Water Problem

2009-10-30 Thread ShingRay
I found an error in my solution. - A*x + B*y = C If x, y are both no non-negative, it takes (x+y)*2 steps. If one of them is negative, it takes (|x|+|y|)*2-1 steps. //There should be abolute value signs We can iterate x from -max(A, B, C) to max(A, B, C) and get many x-y tuples, each of

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

2009-10-30 Thread Shiqing Shen
match the sequence exactly? how to get that polynomial function, i am curious 2009/10/29, Vladimir Reshetnikov v.reshetni...@gmail.com: Any finite sequence of numbers can be matched by polynomial function. On Thu, Oct 29, 2009 at 3:19 PM, Pawandeep bhatti.pawand...@gmail.com wrote:

[algogeeks] aai + bj + ck =0

2009-10-30 Thread ankur aggarwal
Given 3 randomly filled array of size N ( say Aa1,a2..aN , Bb1,b2…bN and Cc1,c2..cN ).give Algorithm to verify if there exists a triplet such that ai + bj + ck =0 where 0I,j,k=N Time complexity of Your algorithm should be O(NlogN) and state space complexity of you’re algorithm .O(N^2) algorithm

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

2009-10-30 Thread Vladimir Reshetnikov
http://en.wikipedia.org/wiki/Lagrange_polynomial On Fri, Oct 30, 2009 at 7:32 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: Any finite sequence of numbers can

[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: Identify The f(x) :you are given a series of numbers(asked by MICROSOFT )?

2009-10-30 Thread umesh kewat
Identify the F(n) required some AI for 1st identify type of sequence whether it is GP, AP, HP or some other special sequence then right the function according the series. On Fri, Oct 30, 2009 at 10:02 AM, Shiqing Shen ssq...@gmail.com wrote: match the sequence exactly? how to get that

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

2009-10-30 Thread daizi sheng
n^2 algo should be obvious, e.g. 1. sort them 2. enumerate ai, bj both in ascending order, then you just need to test ck in descending order instead of enumerating it or you can even make a hash table for C array and then enumerate the first two arrays. On Fri, Oct 30, 2009 at 7:53 PM, ankur

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

2009-10-30 Thread daizi sheng
first n number can not define the full function and so you need to guess. I think you just need a simple enough f(x) to represent the full list, e.g. a closed formula, but you have to define *simple* firstly. I guess Knuth's Concrete Mathematics should help you for more insight. On Thu, Oct

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

2009-10-30 Thread Dave
I would use a language, such as Perl, with which I could easily link to the web page for the Online Encyclopedia of Integer Sequences, using the URL http://www.research.att.com/~njas/sequences/index.html?q=2,4,6,8,10,12language=englishgo=Search (note that the sequence is imbeded in the URL) and

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

2009-10-30 Thread Kamal
In simple terms, if you are going to use only polynomial functions as f (x), this a polynomial curve fitting problem. Here, the input points are (1,2) (2,4) (3,6) and so on... There are many approaches to solve this. You can even consider other functions to model the series according to the

[algogeeks] Master Theorem proof of chip and conquer

2009-10-30 Thread Ani Mkrtoumian
CAN ANYONE HELP ME SOLVE THIS PROBLEM...I KNOW I SHOULD USE SUBSTITUTION BUT THE NEXT STEP IS BLUR! PLEASE! Use Master Theorem to prove that a) The *Chip and be Conquered *recurrence *T(n)=bT(n-c)+f(n), n smallSize, b1, c0* has solution *T(n)**Î**Q**(bn/c)*, if *f(n) **Î** **

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

2009-10-30 Thread Dave
Kamal, wouldn't Microsoft want you to exhibit thinking outside the box on an interview question like this? If so, suggesting something like polynomial regression would be ho-hum. Furthermore, considering Occam's Razor, it would totally miss geometric sequences, the Fibonacci sequence, prime