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

本文详细解答了《算法导论》第三版第五章的两个思考题:5.1 概率计数方法的预期值和方差分析,以及5.2 针对无序数组的随机搜索算法的预期指数。讨论了不同情况下算法的运行时间和性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

算法导论(第三版)参考答案:思考题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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值