作者cai7773 (蓄势待发)
看板CSSE
标题Re: [问题] 未排序的阵列,演算法相关问题
时间Fri Jun 11 01:55:46 2010
Algorithm :
Assume m >= n
Sort array X[1:m] and Y[1:n] Time complexity = O( log m )
For each i = 1:m,
Find d-X[i] in array Y using bisection method
Time complexity = O( m*log n)
Total Time complexity = O( m * log n)
※ 引述《mqazz1 (无法显示)》之铭言:
: given two unsorted arrays X and Y,
: each contains m and n numbers, separately.
: design an algorithm so that,
: given a number d,
: it could determine if there exists two integers i and j,
: such that X[i] + Y[i] = d
: use less than O(m*n) running time
: 我想请问这题大致上从哪方面下手会比较简易
: 谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.121.204.139