Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer c, d and e 1. [10 points] Consider the following algorithm, where rolls is a list of integers. 1 AttackRoll (rolls, AC=10): 2

image text in transcribedplease answer c, d and e

1. [10 points] Consider the following algorithm, where rolls is a list of integers. 1 AttackRoll (rolls, AC=10): 2 for i in rolls: 3 if i 20: 4 print ("Critical!") 5 elif i >= AC and i ! = 1 : print ("Hit!") == Suppose that the input list rolls has n elements. Each element is picked uniformly randomly from the set of integers between 1 and 20. Each element is chosen independently from the others. (a) (1 points) What is the probability that AttackRoll doesn't print anything? Assume that the default value AC=10 is used. Justify your answer carefully: show your work and explain your calculation. (b) (1 points) What is the probability that AttackRoll prints the maximum number of "Hit!? Assume that the default value AC=10 is used. Justify your answer carefully: show your work and explain your calculation. (c) (2 points) What is the expected number of print statements (Hit! or Critical!") that are executed for n 5 rolls? Assume that the default value AC=10 is used. Justify your answer carefully: show your work and explain your calculation. (d) (3 points) Suppose we want to choose the value of AC so that the probability of one or more lines being printed is between 40% and 45% for n = 5 rolls. What value of AC should we choose? Justify your answer carefully: show your work and explain your calculation. (e) (3 points) Suppose that the elements of rolls are each instead generated by choosing the maximum of two independent uniformly randomly generated numbers between 1 and 20. Repeat questions a-c using this new distribution. Justify your answer carefully: show your work and explain your calculation. 1. [10 points] Consider the following algorithm, where rolls is a list of integers. 1 AttackRoll (rolls, AC=10): 2 for i in rolls: 3 if i 20: 4 print ("Critical!") 5 elif i >= AC and i ! = 1 : print ("Hit!") == Suppose that the input list rolls has n elements. Each element is picked uniformly randomly from the set of integers between 1 and 20. Each element is chosen independently from the others. (a) (1 points) What is the probability that AttackRoll doesn't print anything? Assume that the default value AC=10 is used. Justify your answer carefully: show your work and explain your calculation. (b) (1 points) What is the probability that AttackRoll prints the maximum number of "Hit!? Assume that the default value AC=10 is used. Justify your answer carefully: show your work and explain your calculation. (c) (2 points) What is the expected number of print statements (Hit! or Critical!") that are executed for n 5 rolls? Assume that the default value AC=10 is used. Justify your answer carefully: show your work and explain your calculation. (d) (3 points) Suppose we want to choose the value of AC so that the probability of one or more lines being printed is between 40% and 45% for n = 5 rolls. What value of AC should we choose? Justify your answer carefully: show your work and explain your calculation. (e) (3 points) Suppose that the elements of rolls are each instead generated by choosing the maximum of two independent uniformly randomly generated numbers between 1 and 20. Repeat questions a-c using this new distribution. Justify your answer carefully: show your work and explain your calculation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago