Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter C.4, Problem 6E
Program Plan Intro
To determine on the equal number of cases of head, we will get probability as
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Cryptography Algorithm
Q: Say that x^2 = y^2 mod n, but x != y mod n and x != −y mod n.
(a) Show that we found a nontrivial factor of n
Please, answer the whole question. Suppose you toss n biased coins independently. Given positive integers n and k, along with a set of non-negative real numbers p1,..., pn in [0, 1], where pi is the probability that the ith coin comes up head, your goal is to compute the probability of obtaining exactly k heads when tossing these n biased coins. Design an O(nk)-time algorithm for this task. Explain the algorithm, write down the pseudo code and do run time analysis.
Consider the problem of making change for n cents using the fewest number of coins. Assume that we live in a country where coins come in k dierent denominations c1, c2, . . . , ck, such that the coin values are positive integers, k ≥ 1, and c1 = 1, i.e., there are pennies, so there is a solution for every value of n. For example, in case of the US coins, k = 4, c1 = 1, c2 = 5, c3 = 10, c4 = 25, i.e., there are pennies, nickels, dimes, and quarters. To give optimal change in the US for n cents, it is sufficient to pick as many quarters as possible, then as many dimes as possible, then as many nickels as possible, and nally give the rest in pennies.
Design a bottom-up (non-recursive) O(nk)-time algorithm that makes change for any set of k different coin denominations. Write down the pseudocode and analyze its running time. Argue why your choice of the array and the order in which you fill in the values is the correct one. Notice how it is a lot easier to analyze the running time of…
Chapter C Solutions
Introduction to Algorithms
Ch. C.1 - Prob. 1ECh. C.1 - Prob. 2ECh. C.1 - Prob. 3ECh. C.1 - Prob. 4ECh. C.1 - Prob. 5ECh. C.1 - Prob. 6ECh. C.1 - Prob. 7ECh. C.1 - Prob. 8ECh. C.1 - Prob. 9ECh. C.1 - Prob. 10E
Ch. C.1 - Prob. 11ECh. C.1 - Prob. 12ECh. C.1 - Prob. 13ECh. C.1 - Prob. 14ECh. C.1 - Prob. 15ECh. C.2 - Prob. 1ECh. C.2 - Prob. 2ECh. C.2 - Prob. 3ECh. C.2 - Prob. 4ECh. C.2 - Prob. 5ECh. C.2 - Prob. 6ECh. C.2 - Prob. 7ECh. C.2 - Prob. 8ECh. C.2 - Prob. 9ECh. C.2 - Prob. 10ECh. C.3 - Prob. 1ECh. C.3 - Prob. 2ECh. C.3 - Prob. 3ECh. C.3 - Prob. 4ECh. C.3 - Prob. 5ECh. C.3 - Prob. 6ECh. C.3 - Prob. 7ECh. C.3 - Prob. 8ECh. C.3 - Prob. 9ECh. C.3 - Prob. 10ECh. C.4 - Prob. 1ECh. C.4 - Prob. 2ECh. C.4 - Prob. 3ECh. C.4 - Prob. 4ECh. C.4 - Prob. 5ECh. C.4 - Prob. 6ECh. C.4 - Prob. 7ECh. C.4 - Prob. 8ECh. C.4 - Prob. 9ECh. C.5 - Prob. 1ECh. C.5 - Prob. 2ECh. C.5 - Prob. 3ECh. C.5 - Prob. 4ECh. C.5 - Prob. 5ECh. C.5 - Prob. 6ECh. C.5 - Prob. 7ECh. C - Prob. 1P
Knowledge Booster
Similar questions
- Consider the problem of making change for n cents using the fewest number of coins. Assume that we live in a country where coins come in k dierent denominations c1, c2, . . . , ck, such that the coin values are positive integers, k ≥ 1, and c1 = 1, i.e., there are pennies, so there is a solution for every value of n. For example, in case of the US coins, k = 4, c1 = 1, c2 = 5, c3 = 10, c4 = 25, i.e., there are pennies, nickels, dimes, and quarters. To give optimal change in the US for n cents, it is sufficient to pick as many quarters as possible, then as many dimes as possible, then as many nickels as possible, and nally give the rest in pennies. Design a bottom-up (non-recursive) O(nk)-time algorithm that makes change for any set of k different coin denominations. Write down the pseudocode and analyze its running time. Argue why your choice of the array and the order in which you ll in the values is the correct one.arrow_forwardConsider the problem of making change for n cents using the fewest number of coins. Assume that we live in a country where coins come in k dierent denominations c1, c2, . . . , ck, such that the coin values are positive integers, k ≥ 1, and c1 = 1, i.e., there are pennies, so there is a solution for every value of n. For example, in case of the US coins, k = 4, c1 = 1, c2 = 5, c3 = 10, c4 = 25, i.e., there are pennies, nickels, dimes, and quarters. To give optimal change in the US for n cents, it is sufficient to pick as many quarters as possible, then as many dimes as possible, then as many nickels as possible, and nally give the rest in pennies. Prove that the coin changing problem exhibits optimal substructure. Design a recursive backtracking (brute-force) algorithm that returns the minimum number of coins needed to make change for n cents for any set of k different coin denominations. Write down the pseudocode and prove that your algorithm is correct.arrow_forwardno handwritten Alice and Bob are playing a match to see who is the first to win n games, for some fixed n > 0. Suppose Alice and Bob are equally competent, that is, each of them wins a game with probability 1/2. Further, suppose that they have already played i + j games, of which Alice won i and Bob won j. Give an efficient algorithm to compute the probability that Alice will go on to win the match. For example, if i = n − 1 and j = n − 3, then the probability that Alice will win the match is 7/8, since she must win any of the next three games.arrow_forward
- Use secret sharing to find a solution for the secure sum with 3 players • The resulting algorithm should be secure against a maximum of 2 corrupt parties.arrow_forwardSuppose you're flipping a coin 30 times. What R code would give the the probability of flipping: exactly 25 heads at most 16 heads strictly more than 10 headsarrow_forwardthe logit function(given as l(x)) is the log of odds function. what could be the range of logit function in the domain x=[0,1]?arrow_forward
- Flipping a coin 10 times yields heads or tails. How many outcomes have a maximum of four tails?arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. way from block u to obstruct v is a grouping u=x0→x1→x2→⋯→xk=v, where there is a street from block xi−1 to hinder xi for each 1≤i≤k. The length of a way is the amount of lengths over all streets in the way. Two ways x0→x1→⋯→xk and y0→y1→⋯→yl are unique, if k≠l or xi≠yi for some 0≤i≤min{k,l}. Subsequent to moving to another city, Homer just recalls the two exceptional numbers L and R yet fails to remember the numbers n and m of squares and streets, separately, and how squares are associated by streets. Be that as it may, he accepts the number of squares ought to be no bigger than 32 (in light of the fact that the city was little). As the dearest companion of Homer, if it's not too much trouble, let him know whether it is feasible to see as a (L,R)- constant city or not. Input The single line contains two integers L and R (1≤L≤R≤106). Output In case it is difficult to track down a (L,R)- consistent city…arrow_forwardSuppose we use the following KB (where x,y,z are variables and r1, r2, r3, goal are constants) to determine whether a particular robot can score a) Open(x) ∧ HasBall(x) -> CanScore(x) b) Open(x) ∧ CanAssist(y,x) ∧ HasBall(y) -> CanScore(x) c) PathClear(x,y) -> CanAssist(x,y) d) PathClear(x,z) ∧ CanAssist(z,y) -> CanAssist(x,y) e) PathClear(x,goal) -> Open(x) f) PathClear(y,x) -> PathClear(x,y) g) HasBall(r3) h) PathClear(r1, goal) i) PathClear(r2, r1) j) PathClear(r3, r2) k) PathClear(r3, goal) Intuitively, CanScore(x) means x can score on goal. CanAssist(x,y) means there exists some series of passes that can get the ball from x to y. Open(x) means x can shoot on goal directly. And PathClear(x,y) means the path between x and y is clear. Provide a SLD-derivation for the query CanScore(x) in which the answer provided is r1. Provide a SLD-derivation for the query CanScore(x) in which the answer provided is r3. How many "distinct" derivations (i.e., involving different…arrow_forward
- A country has coins with k denominations 1 = d1 < d2 < ... < dk, and you want to make change for n cents using the smallest number of coins. For example, in the United States we have d1 = 1, d2 = 5, d3 = 10, d4 = 25, and the change for 37 cents with the smallest number of coins is 1 quarter, 1 dime, and 2 pennies, which are a total of 4 coins. To solve for the general case (change for n cents with k denominations d1 ... dk), we refer to dynamic programming to design an algorithm. 1. We will come up with sub-problems and recursive relationship for you. Let be the minimum number of coins needed to make change for n cents, then we have: Explain why the above recursive relationship is correct. [Formal proof is not required] 2. Use the relationship above to design a dynamic programming algorithm, where the inputs include the k denominations d1 ... dk and the number of cents n to make changes for, and the output is the minimum number of coins needed to make change for n. Provide…arrow_forwardShow that for f(n) = 2n2 and g(n) = 20n + 3n2 , f(n) is θ(g(n)). How many ways can it be shown? Also Show that for g(n) = 10n2and f(n) = n! + 3 , f(n) is Ω(g(n)). How many ways can it be shown? Discuss with the instructor.arrow_forwardQuestion 15 pap Suppose we have a Monte Carlo algorithm, A, and a deterministic algorithm, B, for testing if the output of A is correct. How can we use A and B to construct a Las Vegas algorithm? Also, if A succeeds with probability ½ and both A and B run O(n) time, what is the expected running time of the Las Vegas algorithm that is produced? Full explain this question and text typing work only We should answer our question within 2 hours takes more time then we will reduce Rating Dont ignore this linearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole