[algogeeks] Re: Given N numbers z value , find x, y such that x + y = z

2006-01-01 Thread Daniel Zhou
Actually, there is a method to solve this problem in O(3/2 * n) Assume the maximum value is m, minimum value is n 1. hash these value into a table, with size m - n + 1, cost O(n), assume this table is noted as H 2. {(x, y) | x + y = z} must be reside in H followed by this condition: {(x, y)

[algogeeks] Re: Given N numbers z value , find x, y such that x + y = z

2006-01-01 Thread Daniel Zhou
Actually, there is a method to solve this problem in O(3/2 * n) Assume the maximum value is m, minimum value is n 1. hash these value into a table, with size m - n + 1, cost O(n), assume this table is noted as H 2. {(x, y) | x + y = z} must be reside in H followed by this condition: {(x, y)

[algogeeks] Re: Finding Repeated and Missing Numbers

2006-01-01 Thread Vinodh Kumar
Hi, I think there is a small modification in the equations : X= (D2 + D1^2)/(2*D1) Y= (D2 - D1^2)/(2*D1) Vinodh

[algogeeks] Re: Finding Repeated and Missing Numbers

2006-01-01 Thread Swadhin Sonowal
You are right. I made a mistake while typing the equation. Thanks. swadhin On 1/2/06, Vinodh Kumar [EMAIL PROTECTED] wrote: Hi, I think there is a small modification in the equations : X= (D2 + D1^2)/(2*D1) Y= (D2 - D1^2)/(2*D1) Vinodh