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 5.1, Problem 3E
Program Plan Intro
To give an
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A language has an alphabet of four letters x;, i = 1,2,3,4, each occurring with probability1/4.
Find the number of bits needed of a fixed-length binary code in which:
a. Each letter is encoded separately into a binary sequence.
b. Two letters at a time are encoded into a binary sequence.
Which method is efficient in the sense of bit per letter?
Let's consider a long, quiet country road with houses scattered very sparsely along it. (Picture the road as a long line segment with an eastern endpoint and a western endpoint.) Further let’s suppose that despite the bucolic setting, the residents of all these houses are avid cell phone users. You want to place cell phone base stations at certain points along the road, so that every house is within four miles of one of the base stations. Give an efficient algorithm that achieves this goal using as few base stations as possible. Prove its correctness and explain its time complexity.
Write a python program by following rules:
Has ? discrete time intervals where ? is large.
Generates a set of customer call arrivals with the arrival rate of ? at random locations in the ? intervals (e.g., for each interval, a call will happen with probability ?/?).
Counts the number of calls that actually occurs during these ? intervals.
Design your experiment to determine the Poisson distribution of this experiment (probability of having k arrivals in n intervals).
Chapter 5 Solutions
Introduction to Algorithms
Knowledge Booster
Similar questions
- write a computer program that produces the desired output from the given input. Input: A random variable and a probability distribution for a finite sample space.Output: The expected value of the random variable.arrow_forward2. A celebrity among a group of n people is a person who knows nobody but is known by everybody else. Design a decrease-and-conquer algorithm that identifies a celebrity among n people, or outputs "no celebrity identified" if there is no such person, by only asking the question "Do you know him/her?" to people. Analyze the efficiency of the algorithm.arrow_forwardYou are given a collection of n bolts of different widths and n correspondingnuts. You are allowed to try a nut and bolt together, from which you can determine whether the nut is larger than the bolt, smaller than the bolt, or matches the bolt exactly. However, there is no way to compare two nuts together or two bolts together. The problem is to match each bolt to its nut. Design an algorithm for this problem with an average-case efficiency ofΘ(n log n).arrow_forward
- Consider the functionf :: Int -> Intf n = if n==0then 0else 1 + (f(n-1))Use induction to show that the function f returns the value of n for all possible inputs n ≥0.Here are the steps:1. Verify that f 0 returns 0 to show the base case.2. Show that if f(n-1) returns n −1 then f n returns n.3. Since you have shown the base case and the induction step, you can confidentlystate that the function works for all possible nonnegative input values.Hint: To show that ”if f(n-1) returns n −1 then f n returns n” is valid you need toassume that f(n-1) returns n −1 and then argue that it must follow that f n returnsn. Use the definition of the function and just a little bit of algebra.Criteria for Success: You have clearly written down all three steps of the inductive proof. Your proof contains complete sentences which explain all the steps andthe algebra. I don’t want to see just a bunch of symbols on a page!arrow_forwardApply gaussian random walk(walking in a random direction with each step of length 1. i.e. each time at random theta it will walk cos(theta) at x, sin(theta) at y). What is the probability that the walk starting at (0,0) will end at (5,5)? How to simulate it in python?arrow_forwarddesigned an iterative algorithm for separating n VLSIchips into those that are good and those that are bad by testing two chips at a time andlearning either that they are the same or that they are different. To help, at least half ofthe chips are promised to be good. Now design (much easier) a randomized algorithmfor this problem. Here are some hints. Randomly select one of the chips. What is the probability that the chip is good? How can you learn whether or not the selected chip is good? If it is good, how can you easily partition the chips into good and bad chips? If the chip is not good, what should your algorithm do? When should the algorithm stop? What is the expected running time of this algorithm?arrow_forward
- The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit. For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yields 3, a single digit and also the digital root of 39. Input File: The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero. Output File: For each integer in the input, output its digital root on a separate line of the output. Example Input: 24 39…arrow_forwardYou are given a collection of n bolts of different widths and n corresponding nuts. You are allowed to try a nut and bolt together, from which you can determine whether the nut is larger than the bolt, smaller than the bolt, or matches the bolt exactly. However, there is no way to compare two nuts together or two bolts together. The problem is to match each bolt to its nut. Design an algorithm for this problem with average-case efficiency in Θ(n log n).arrow_forwardLet pn(x) be the probability of selling the house to the highest bidder when there are n people, and you adopt the Look-Then-Leap algorithm by rejecting the first x people. For all positive integers x and n with x < n, the probability is equal to p(n(x))= x/n (1/x + 1/(x+1) + 1/(x+2) + … + 1/(n-1)) If n = 100, use the formula above to determine the integer x that maximizes the probability n = 100 that p100(x). For this optimal value of x, calculate the probability p100(x). Briefly discuss the significance of this result, explaining why the Optimal Stopping algorithm produces a result whose probability is far more than 1/n = 1/100 = 1%.arrow_forward
- Recall the Monte Carlo method, from week 6 (section 6.2.2), for approximating . Suppose we choose a point (x, y) randomly (with uniform distribution) in the unit square. The probability that it lies inside a circle of diameter 1 contained in the unit square is equal to the area of that circle, or π/4. So this Monte Carlo method works as follows: Write a function montecarlo (M) which takes an integer M and returns an approximation to π. (I can't give you an example output, as the random nature of the procedure means approximations will differ!)arrow_forwardImagine you have a strip of highway connecting n towns in a line. Each town is being evaluated as a possible location for building a cellular phone tower. Each cell tower will provide coverage to the town it’s built in, but no other towns. However, due to the way that cell towers interfere with one another, it’s not possible to build cell phone towers in two adjacent towns.Describe an algorithm that, given the populations of each of the towns, reports the maximum number of people you can provide cell phone coverage to, subject to the restriction that no two adjacent towns can each have cell towers in them. Use dynamic programming to dramatically speed up your solution over a na ̈ıve recursive algorithm.arrow_forwardan iterative algorithm for separating n VLSI chips into those that are good and those that are bad by testing two chips at a time and learning either that they are the same or that they are different. To help, at least half of the chips are promised to be good. Now design (much easier) a randomized algorithm for this problem. Here are some hints.Randomly select one of the chips. What is the probability that the chip is good? How can you learn whether or not the selected chip is good? If it is good, how can you easily partition the chips into good and bad chips? If the chip is not good, what should your algorithm do? When should the algorithm stop? What is the expected running time of this algorithm?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education