Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 5, Problem 1P

(a)

Program Plan Intro

To show that the expected value represented by the counter after n INCREMENT operations that have been performed is exactly n.

(a)

Expert Solution
Check Mark

Explanation of Solution

Given Information: The INCREMENT operation works on a counter containing the value i in a probabilistic manner. If i=2b1 then it shows an overflow error. Otherwise, it increases the counter by 1 with probability 1/(ni+1ni) and leaves the counter with probability 11/(ni+1ni) .

Explanation:

The counter after n INCREMENT operations is performed exactly n times for the expected value.

Consider that the initial value of the counter is i and increasing the number representation from ni to ni+1 with a probability of 1ni+1ni and leaving the value unchanged.

The expected increase is calculated as,

  ni+1nini+1ni=1

Hence, the expected increment represented by the counter is 1.

(b)

Program Plan Intro

To calculate the variance in the value represented by the register after n INCREMENT operations have been performed.

(b)

Expert Solution
Check Mark

Explanation of Solution

Given Information: Consider a simple case: ni=100i for all i0 and variance of the counter depends on the ni .

Explanation:

Consider that Vn and Xj are the variant and pairwise independent events. The variance Vn is calculated as,

  Var[Vn]=Var[X1]+Var[X2]+Var[Xn]

Since ni=100i and ni+1ni=100(i+1)100i=100 . Therefore, the value represented by the counter with probability 99/100 due to the jth INCREMENT is 0 and with the probability of 1/100 .

The value represented increases by 100. Therefore, by the equation (C.27)

  Var[Xj]=E[Xj2]E2[Xj]=(( 0 2 99 100 )+( 100 2 1 100 ))12=1001=99

Now, adding the variances of the Xj gives Var[Vn]=99n .

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Mathematical Induction: Binet's formula is a closed form expression for Fibonacci numbers. Prove that binet(n) =fib(n). Hint: observe that p? = p +1 and ² = b + 1. function fib(n) is function binet(n) is match n with let case 0 → 0 2 case 1 1 otherwise in L fib(n – 1) + fib(n – 2) V5
Let, a1 = 3, a2 = 4 and for n ≥ 3, an = 2an−1 + an−2 + n2, express an in terms of n.
3. Prove by induction that T(n) = 2T (n/2) + cn is O(n logn).
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education