《算法导论》第五章-思考题(参考答案)

算法导论(第三版)参考答案:思考题5.1,思考题5.2

Problem 5.1 (Probabilstic counting)

With a b -bit counter, we can ordinarily only count up to 2b1 . With R. Morris’s probabilistic counting, we can count up to a much larger value at the expense of some loss of precision.

We let a counter value of i represent that a count of ni for i=0,1,,2b1 , where the ni form an increasing sequence of nonnegative values. We assume that the initial value of the counter is 0 , representing a count of n0=0 . The INCREMENT operation works on a counter containing the value i in a probabilistic manner. If i=2b1 , then the operation reports an overflow error. Otherwise, the INCREMENT operation increases the counter by 1 with probability 1/(ni+1ni) , and it leaves the counter unchanged with probability 11/(ni+1ni) .

If we select ni=i for all i0 , then the counter is an ordinary one. More interesting situations arise if we select, say, ni=2i1 for i>0 or ni=Fi (the ith Fibonacci number - see Section 3.2).

For this problem, assume that n2

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值