4. Stochastic algorithms: A programmer can choose between two algorithms (A and B) to solve a problem that we call "Q". Algorithm A is deterministic, i.e. it is guaranteed to find an answer, and always takes the same time (20 hours) to solve Q. Algorithm B is stochastic, i.e. it makes use of random numbers internally, but we will not "look inside" the algorithm. Algorithm B does not always find an answer, but it runs quickly. It always has a running time of 0.5 hours (on problem Q), regardless of whether it succeeds in finding an answer or not, and it gives a message when it fails. Therefore, B must be run several times until it finds the answer. We define p = P (B finds the answer) for a single run, and that different runs of B are independent (with regard to whether they find the answer or not). (a) If p = 0.04, what is the expected total running time before algorithm B finds an answer? Should the programmer choose algorithm A or B for problem Q? (Hint: look at geometric distribution)

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
icon
Related questions
Question
4. Stochastic algorithms: A programmer can choose between two algorithms (A and B) to solve a
problem that we call "Q". Algorithm A is deterministic, i.e. it is guaranteed to find an answer, and
always takes the same time (20 hours) to solve Q. Algorithm B is stochastic, i.e. it makes use of
random numbers internally, but we will not "look inside" the algorithm. Algorithm B does not always
find an answer, but it runs quickly. It always has a running time of 0.5 hours (on problem Q),
regardless of whether it succeeds in finding an answer or not, and it gives a message when it fails.
Therefore, B must be run several times until it finds the answer. We define p = P (B finds the answer)
for a single run, and that different runs of B are independent (with regard to whether they find the
answer or not).
(a) If p = 0.04, what is the expected total running time before algorithm B finds an answer? Should
the programmer choose algorithm A or B for problem Q? (Hint: look at geometric distribution)
Transcribed Image Text:4. Stochastic algorithms: A programmer can choose between two algorithms (A and B) to solve a problem that we call "Q". Algorithm A is deterministic, i.e. it is guaranteed to find an answer, and always takes the same time (20 hours) to solve Q. Algorithm B is stochastic, i.e. it makes use of random numbers internally, but we will not "look inside" the algorithm. Algorithm B does not always find an answer, but it runs quickly. It always has a running time of 0.5 hours (on problem Q), regardless of whether it succeeds in finding an answer or not, and it gives a message when it fails. Therefore, B must be run several times until it finds the answer. We define p = P (B finds the answer) for a single run, and that different runs of B are independent (with regard to whether they find the answer or not). (a) If p = 0.04, what is the expected total running time before algorithm B finds an answer? Should the programmer choose algorithm A or B for problem Q? (Hint: look at geometric distribution)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman