deepayan@isid.ac.in
>Assignments are meant to be done individually, not in groups. You are welcome to discuss ideas with others, but you may not share actual code, algorithms, etc.
Due: November 1, 2019. Submit typed report as PDF file along with R and C++ code files by email.
Due: January 12, 2020. Submit a typed narrative report as PDF file along with relevant R and C++ code files by email.
Suppose you are given an
algorithm rcoin()
that produces
either 0 or 1, with equal probability, every time
it is invoked. Assume that the outcome of
different calls are independent of each other.
rcoin()
as a random number
generator, write an algorithm r100()
that produces a random integer between 0 and 99
(inclusive).rcoin()
. If your algorithm is a
randomized algorithm, compute the expected number of times it
invokes rcoin()
. The quicksort algorithm can be modified as follows to compute a specific order statistic (i.e., quantile) in linear time (in the average case): after the partition step, the recursion is called only on one subarray, namely, the one containing the desired quantile.
order_statistic(x, w)
to
compute an order statistic, so that the call
order_statistic(x, w)
returns
the w
-th order statistic
of x
,
i.e., sort(x)[w]
, but without
actually sorting x
.
order_statistic(x, w)
. Submit
the C++ code as a file
named order.cpp
.
simulation.R
.