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.
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
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps with 9 images
Knowledge Booster
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
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
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…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
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…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,