Problem 4. Suppose you are given a set of small boxes, numbered 1 to n, identical in every aspect except that each of the first i contains a pearl whereas the remaining n − i are empty. You can have two magic wands that can each test if a box is empty or not in a single touch, except that a wand disappears if you test it on a box that is empty. Show that, without knowing the value of i, you can use the two wands to determine all the boxes containing pearls using at most no more than 2√ n wand touches. Hint: For a suitable parameter k that you choose consider using one wand on boxes 1, k, 2k, 3k, . . .; find the value i where the empty box is among (i − 1)k + 1, . . . , ik. Then use the second wand sequentially from (i − 1)k + 1 to ik − 1 to the empty box. The total number of touches will be at most: n/k + k. Then, let k = √ n (think about why this value of k; why not, e.g., let k = n 0.4 ?).
First use one wand on boxes 1, k, 2k, 3k,......
The smallest i for which the wand burns on box i * k indicates that the first empty box is among (i - 1) *k + 1 to i*k - 1 to find it.
The total number of touches will be at most: n/k + k
Where n/k => number of boxes for the first wand and
k => for the second wand
If we chose k to be
, then we have
tha is:
touches
Problem 4. Suppose you are given a set of small boxes, numbered 1 to n, identical...
Question 29 (4 points) Two boxes each contain five numbered balls: • Box 1 contains balls with numbers 3, 3, 3, 4, 5 • Box 2 contains balls with numbers 1, 1, 2, 2, 2 (a) You will randomly select one ball from each box. Let X be the difference between the numbers selected from the first and second box. Find the probability distribution of X. You can simply list the probabilities for each possible value of X instead of...
1 10 onvelge a636lutely, converges conditionally, or diverges. Justify your answer, including naming the convergence test you use. (1n(b) n7/3-4 (2k)! n-2 k-0 (-1)k 2k 4. (a) (10) Let* Find a power series for h(), and find the radius of convergence Ri for h'(x). Find the smallest reasonable positive integer n so that - (b) (10) Let A- differs from A by less than 0.01. Give reasons. 5. (a) (10) Let g(x) sin z. Write down the Taylor series for...
Maximum Value But Limited Neighbors You are given an array a[1..n] of positive numbers and an integer k. You have to produce an array b[1..n], such that: (i) For each j, b[j] is 0 or 1, (ii) Array b has adjacent 1s at most k times, and (iii) sum_{j=1 to n} a[j]*b[j] is maximized. For example, given an array [100, 300, 400, 50] and integer k = 1, the array b can be: [0 1 1 0], which maximizes the...
You are given a set of integer numbers A = {a1, a2, ..., an}, where 1 ≤ ai ≤ m for all 1 ≤ i ≤ n and for a given positive integer m. Give an algorithm which determines whether you can represent a given positive integer k ≤ nm as a sum of some numbers from A, if each number from A can be used at most once. Your algorithm must have O(nk) time complexity.
In Problem Set 7 you designed and implemented a Message class. This time, let's design and implement a Mailbox class in a file named Mailbox java. Do the following with this class • You may use the Message class from PS 7. You will have to add new features to the Message class from PS 7 as you work through this problem. You are welcome to start with my sample solution if you wish • Suppose there are multiple mail...
Suppose we are given two sorted arrays (nondecreasing from index 1 to index n) X[1] · · · X[n] and Y [1] · · · Y [n] of integers. For simplicity, assume that n is a power of 2. Problem is to design an algorithm that determines if there is a number p in X and a number q in Y such that p + q is zero. If such numbers exist, the algorithm returns true; otherwise, it returns false....
Problem 5.10.10 Suppose you have n suitcases and suitcase i holds Xi dollars where X1, X2, …, Xn are iid continuous uniform (0, m) random variables. (Think of a number like one million for the symbol m.) Unfortunately, you don’t know Xi until you open suitcase i. Suppose you can open the suitcases one by one, starting with suitcase n and going down to suitcase 1. After opening suitcase i, you can either accept or reject Xi dollars. If...
Can anyone help me with this problem? Thank you!
7. Let X1,.. , Xn denote a random sample from (1-9)/0 x; Test Ho: θ Bo versus H1: θ θο. (a) For a sample of size n, find a uniformly most powerful (UMP) size-a test if such exists. (b) Take n-?, θ0-1, and α-.05, and sketch the power function of the UMP test.
7. Let X1,.. , Xn denote a random sample from (1-9)/0 x; Test Ho: θ Bo versus H1:...
Problem 5.10.10 Suppose you have n suitcases and suitcase i holds Xi dollars where X1, X2, …, Xn are iid continuous uniform (0, m) random variables. (Think of a number like one million for the symbol m.) Unfortunately, you don’t know Xi until you open suitcase i. Suppose you can open the suitcases one by one, starting with suitcase n and going down to suitcase 1. After opening suitcase i, you can either accept or reject Xi dollars. If you...
Haloo , i have java program , Java Program , dynamic program Given a knapsack with capacity B∈N and -n- objects with profits p0, ..., p n-1 and weights w0, ..., wn-1. It is also necessary to find a subset I ⊆ {0, ..., n-1} such that the profit of the selected objects is maximized without exceeding the capacity. However, we have another limitation: the number of objects must not exceed a given k ∈ N Example: For the items...