searching algorithm enquiry
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 7 楼,当前显示第 2 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:sc2 (等级:2 - 初出茅庐,发帖:84) 发表:2003-07-28 11:06:52  2楼  评分: 
er,
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!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 7 楼,当前显示第 2 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码