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.

Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
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.
Similar questions
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Basic Technical Mathematics
Basic Technical Mathematics
Advanced Math
ISBN:
9780134437705
Author:
Washington
Publisher:
PEARSON
Topology
Topology
Advanced Math
ISBN:
9780134689517
Author:
Munkres, James R.
Publisher:
Pearson,