er,
所在版块:求学狮城 发贴时间:2003-07-28 11:06  评分:

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
The worst case performance is very difficult to improve, which is lg(n)

You can improve the averge case performance, by the following data structure:
(I suggested)
Divide the [0, 1) into 64 equally spanned intervels,by b1=1/64, b2=2/64, ...

Record into B which interval of A that bi belongs to.

If B[i]=B[i+1], then you meet a nice case when the randon number fall into
b[i], b[i+1], otherwise, you maybe need to divide B[i] recursively.

To implement this will be tedious. You are can compute that the average
case for this datastructure will be O(1).

Hope that will be helpful
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

Put your OWN COOL signature here!
 相关帖子 我要回复↙ ↗回到正文
searching algorithm enquiry wangye   (596 bytes , 326reads )
er, sc2   (582 bytes , 274reads )
thanx very much for sc2's suggestion, but wangye   (415 bytes , 211reads )
welcome, and sc2   (677 bytes , 166reads )
不好意思的说,可能是我太笨了 wangye   (122 bytes , 165reads )
we discuss it with email bah sc2   (35 bytes , 151reads )
no problem wangye   (21 bytes , 187reads )