searching algorithm enquiry
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 7 楼,当前显示第 5 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:wangye (等级:2 - 初出茅庐,发帖:62) 发表:2003-07-29 21:55:01  5楼 
welcome, andB[i] records the A's interval ID(the index, not the real value). and B's size is not necesarily to be 64, say, can be 200. if B[i]=B[i+1], then B[i] is the value u want. otherwise B[i+1]>B[i], you may just sub-divide the range [i/64, (i+1)/64). Otherwise, you can just do a liear scan from A[B[i]] to A[B[i+1]], the expect number of intervals tp be scanned should be very small (O(1)). The worst case can be large as larger as A's size (you can do a binary search again (O(lgn)), but the overhead will be large). Yup, A is random and sorted in increasing order?!, if u want to find the right interval by comparison, the worst case bound is O(lgn), and hard to improve. :)
不好意思的说,可能是我太笨了
我知道B[i]是INDEX

可B[i]=B[i+1]只说明b[i],b[i+1]在相同的区间内, 能说明 a 也在这个区间内吗? a 和 b[i],b[i+1] 没任何关系吧.
Put your OWN COOL signature here!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

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



请登录后回复:帐号   密码