Question: 1 ) Consider the following pseudo code: Function Test ( x , y , z ) { read ( x ) ; if x <

1) Consider the following pseudo code:
Function Test ( x , y, z ){ read ( x ) ; if x <10 then { y = x * y; z = y*z ;}
else if x <50 then { y = x * y ; }
else { y = x * z ; z = x *y; x = z * y; }
}
Main (){ read (n);
for i =1 to n do {
Test(x, y, z)
Print(x, y, z)}
}
Suppose that x is a random variable where the probabilities of
x <10,10<= x <50,50<= x are 0.35,0.4 and 0.25 respectively.
- How many multiplications are done in the worst-case, average-case (expected
case) and best-case (all expressed as a function of n)?
- How many prints?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!