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
Write a FancyCar class to support basic operations such as drive, add gas, honk horn, and start engine. FancyCar.java is provided with method stubs. Follow each step to gradually complete all methods. Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main() method includes basic method calls. Add statements in main() as methods are completed to support development mode testing. Step 0. Declare private fields for miles driven as shown on the odometer (int), gallons of gas in tank (double), miles per gallon or MPG (double), driving capacity (double), and car model (String). Note the provided final variable indicates the gas tank capacity of 14.0 gallons. Step 1 (2 pts). 1) Complete the default constructor by initializing the odometer to five miles, tank is full of gas, miles per gallon is 24.0, and the model is "Old Clunker". 2)…
Find the error: daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday',                     'Wednesday', 'Thursday', 'Friday',                     'Saturday'] for i in range(7):         daily_sales[i] = float(input('Enter the sales for ' \                                      + day_of_week[i] + ': ')
Find the error: daily_sales = [0.0, 0,0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday',                     'Wednesday', 'Thursday', 'Friday',                     'Saturday'] for i in range(7):         daily_sales[i] = float(input('Enter the sales for ' \                                      + days_of_week[i] + ': ')
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning