Question 4 Suppose we are given an array A[0...n – 1] of size n, where each array entry has a value that is chosen uniformly at random in {1,...,95}. Consider an algorithm that takes as input a value r € {1,..., 95}, and searches for a in the array by querying array entries A[i] for ie {0,...,n- 1} in increasing order of i. Whenever the algorithm queries an array entry A[i] that has value r, it immediately outputs the index i. (a) What is the expected number of indices that the algorithm outputs? (b) For any k E {0,..., n – 1}, what is the probability that the smallest index the algorithm outputs is k? (c) How does the answer to (b) change, if we know that at least one array entry has value æ? Explain and show all your calculations.

Elements Of Modern Algebra
8th Edition
ISBN:9781285463230
Author:Gilbert, Linda, Jimmie
Publisher:Gilbert, Linda, Jimmie
Chapter2: The Integers
Section2.3: Divisibility
Problem 49E: 49. a. The binomial coefficients are defined in Exercise of Section. Use induction on to prove...
icon
Related questions
Question
Question 4
Suppose we are given an array A[...n – 1] of size n, where each array entry has a value that
is chosen uniformly at random in {1,..., 95}. Consider an algorithm that takes as input a value
x € {1, ...,95}, and searches for a in the array by querying array entries A[i] for i e {0,...,n- 1}
in increasing order of i. Whenever the algorithm queries an array entry A[i] that has value r, it
immediately outputs the index i.
(a) What is the expected number of indices that the algorithm outputs?
(b) For any k E {0, ...,n - 1}, what is the probability that the smallest index the algorithm outputs
is k?
(c) How does the answer to (b) change, if we know that at least one array entry has value a?
Explain and show all your calculations.
Transcribed Image Text:Question 4 Suppose we are given an array A[...n – 1] of size n, where each array entry has a value that is chosen uniformly at random in {1,..., 95}. Consider an algorithm that takes as input a value x € {1, ...,95}, and searches for a in the array by querying array entries A[i] for i e {0,...,n- 1} in increasing order of i. Whenever the algorithm queries an array entry A[i] that has value r, it immediately outputs the index i. (a) What is the expected number of indices that the algorithm outputs? (b) For any k E {0, ...,n - 1}, what is the probability that the smallest index the algorithm outputs is k? (c) How does the answer to (b) change, if we know that at least one array entry has value a? Explain and show all your calculations.
Expert Solution
steps

Step by step

Solved in 5 steps with 9 images

Blurred answer
Knowledge Booster
Paths and Circuits
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, advanced-math and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Elements Of Modern Algebra
Elements Of Modern Algebra
Algebra
ISBN:
9781285463230
Author:
Gilbert, Linda, Jimmie
Publisher:
Cengage Learning,