searching algorithm enquiry
所在版块:求学狮城 发贴时间:2003-07-27 22:56

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
请教PROGRAMMING高手们:

If i divide the interval I=[0,1) into, say, 64 subintervals, and recode the 64 left pts into an Array A[0:63] in ascending order, how can I decide which interval a random number a (- [0,1) is in with the LEAST possible loopings?

The method I use now is : start from the centre A[33], check if a>A[33]. if yes, check the centre of the upper half
if a>A[49]; else check centre of the lower half if a>A[17]. So on and so forth, just like the idea of a binary ADC converter. but i need 6 looping interation in order to get the answer. Any one knows faster method than this?
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

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