Question: Problem Description Given the pseudocode below to find a target number I between 1 and r ( both Inclusive ) : while ( 1 )

Problem Description
Given the pseudocode below to find a target number I between 1 and r (both Inclusive):
while (1){
int - i * d =(1+ r)/2 if (i mid) r = pi*id - t else if (i >= id)1mid+1; else 1 print("Found");
break:
1
You are required to answer q queries, where in each query, you will be provided with values 1 and r For each query, determine the following:
What is the probability that the above code will fall to print "Found" when any value i (where l <- i < r ) is chosen? Express this probability as an integer where the fraction SP/Q and gcd(P. Q)1. You should compute P = Q ^ lambda -1 modulo 1019.7 where QA-1 denotes the multiplicative inverse of a modulo 108947
Problem Constraints f=A\|||0|

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!