Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have m bins, and n balls. Each time you throw a ball, it lands in one of the m bins with probability 1 m

You have m bins, and n balls. Each time you throw a ball, it lands in one of the m
bins with probability 1m. What is the expected number of bins that contain at least
2 balls?
In the code below, we define random (n) which returns iin[n] with probability 1n, in
(1)-time, and CoinFlip simply returns 0 or 1, each with probability 12.
import math
import random
# returns a random integer in 1,n
def random(n) :
return random. randint (1,n)
# returns a random integer in ,1
def coinflip():
return random(2)-1
For each function that follows, give each function's best case, worst case, and average
case asymptotic running times. Justify your answer.
(a)
import random
import math
def f1(xs) :
s=
n=len(xs)
k=random(n)
math.sqrt (n))
if k=1 :
m=n??2
for j in range (m) :
s**=xs[j]
return s
image text in transcribed

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago