(Simulation: coupon collector’s problem) Coupon collector is a classic statistics problem with many practical applications. The problem is to repeatedly pick objects from a set of objects and find out how many picks are needed for all the objects to be picked at least once. A variation of the problem is to pick cards from a shuffled deck of 52 cards repeatedly, and find out how many picks are needed before you see one of each suit. Assume a picked card is placed back in the deck before picking another. Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
Additional Engineering Textbook Solutions
C Programming Language
Java: An Introduction to Problem Solving and Programming (7th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Digital Fundamentals (11th Edition)
Absolute Java (6th Edition)
- Python Programing: Sahil is an outstanding entertainer. He is expert in what he does. At a day, he accepted Samir's challenge to plant 20 million trees by 2020. Currently, there are N trees (numbers 1 to N) planted in different places in the row; for each valid I, the location of the i-Ayi tree. A bunch of trees is good if for each tree in this set (let's say its place in x), there is a tree in x - 1 and / or a tree in x + 1. Sahil task is to plant more trees (perhaps zero) in such a way that the effect of all the trees planted (the first N trees and the ones planted by Sahil) is good. It is only allowed to plant trees in complete (perhaps unfavorable) areas. Help Sahil to find the minimum number of trees they need to plant to achieve that using Python Programming. Input: 1 3 538 Output: 3.arrow_forwardplease code in python You place a pawn at the top left corner of an n-by-n chess board, labeled (0,0). For each move, you have a choice: move the pawn down a single space, or move the pawn down one space and right one space. That is, if the pawn is at position (i,j), you can move the pawn to (i+1,j) or (i+1, j+1). Ask the user for the size of a chessboard, n (integer). Find the number of different paths starting from (0,0) that the pawn could take to reach each position on the chess board. For example, there are two different paths the pawn can take to reach (2,1). Look at the diagrams below to convince yourself of this. You can see the four paths that you can take by move 2. Start -> Move 1 -> Move 2 (0,0) -> (1,0) -> (2,1) (0,0) -> (1,0) -> (2,0) (0,0) -> (1,1) -> (2,1) (0,0) -> (1,1) -> (2,2) Print the board with the number of ways to reach each square labeled as shown below. For example: Enter a board size: 4 1 0 0 0 1 1 0 0 1 2 1 0 1 3 3 1arrow_forwardC++ Programming, Arrays Lights The park is illuminated by n (1 < n < 100) lights. Each of them shines all night or not. Of course, which lights were on the first night and which were not. Every other night the condition of the lamps shall be determined by the following rules: the lamp will not illuminate if both of its neighbors were lit last night; the lamp shall illuminate if one of its neighbors was illuminated last night and the other was not; if neither of the first two rules applies to the lamp, it will illuminate when the night is even and will not illuminate when the night is odd. Create a program to determine which lights are on and which will not be lit when k (1 < k < 100) nights have elapsed, and to find which night the most lights were lit and which the least. If there are several identical nights with the most or least lights lit, the night with the lower number must be indicated. The first line of the original data file contains two integers: the number of…arrow_forward
- 2: (Knapsack Problem) Using exhaustive search, find the most valuable subset of items that fit into the knapsack if the knapsack capacity is 10kg. Since it is exhaustive search, you need to show all possible options of picking the objects, calculate the value for each, mark those which are not feasible, and pick the best. Weight (kg) 5 6 5 Item 1 2 3 Ans: Subset Total weight Total value Value $10 $15 $10arrow_forwardPython quesarrow_forwardPython Programming Lab Dr.D has invented yet another invention: the hateinator. He wants to test it on a group of N people (numbered 1 through N). The hateinator may be used any number of times; to use it once, Dr.D should divide these N people into two groups and press the fire button on the hateinator. We call each such grouping a Doofish set. Afterwards, there will be hatred between each two people who were in different groups. The hatred does not disappear ― any two people that hate each other before the hateinator is used still hate each other afterwards. The hateinator uses a lot of power. Let's denote the number of times it is used by K. Then, it consumes K⋅N units of power. Dr.D cannot afford to use the hateinator if this number exceeds 106. Dr.D has done the math and computed the most evil hatred system: a situation with some M pairs of people who hate each other. You are given these pairs. There must not be any other pair of people who hate each other. Initially, there is no…arrow_forward
- Computer Science This is an introductory exercise to the manipulation of random variables with Python as a language for scientific computing and numerical computation. You have: f(x) = Ae-0.1x)° 4 x*, 0arrow_forwardPLEASE CODE IN PYTHON The Penny Pitch game is popular in amusement parks. Pennies are tossed onto a board that has certain areas marked with different prizes. For example: The prizes available on this board are puzzle, game, ball, poster, and doll. At the end of the game, if all of the squares that say BALL are covered by a penny, the player gets the ball. This is also true for the other prizes. The board is made up of 25 squares (5 x 5). Each prize appears on three randomly chosen squares so that 15 squares contain prizes.In Python, create a PennyPitch application that displays a Penny Pitch board (use [ and ] to indicate squares) with prizes randomly placed and then simulates ten pennies being randomly pitched onto the board. After the pennies have been pitched, the application should display a message indicating which prizes have been won, if any.arrow_forwardCCC '13 J1 - Next in line Canadian Computing Competition: 2013 Stage 1, Junior #1 You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years. Given the ages of the youngest and middle children, what is the age of the oldest child? Input Specification The input consists of two integers, each on a separate line. The first line is the age Y of the youngest child (0arrow_forward(Python matplotlib or seaborn) CPU Usage We have the hourly average CPU usage for a worker's computer over the course of a week. Each row of data represents a day of the week starting with Monday. Each column of data is an hour in the day starting with 0 being midnight. Create a chart that shows the CPU usage over the week. You should be able to answer the following questions using the chart: When does the worker typically take lunch? Did the worker do work on the weekend? On which weekday did the worker start working on their computer at the latest hour? cpu_usage = [ [2, 2, 4, 2, 4, 1, 1, 4, 4, 12, 22, 23, 45, 9, 33, 56, 23, 40, 21, 6, 6, 2, 2, 3], # Monday [1, 2, 3, 2, 3, 2, 3, 2, 7, 22, 45, 44, 33, 9, 23, 19, 33, 56, 12, 2, 3, 1, 2, 2], # Tuesday [2, 3, 1, 2, 4, 4, 2, 2, 1, 2, 5, 31, 54, 7, 6, 34, 68, 34, 49, 6, 6, 2, 2, 3], # Wednesday [1, 2, 3, 2, 4, 1, 2, 4, 1, 17, 24, 18, 41, 3, 44, 42, 12, 36, 41, 2, 2, 4, 2, 4], # Thursday [4, 1, 2, 2, 3, 2, 5, 1, 2, 12, 33, 27, 43, 8,…arrow_forwardStudents in a basic statistics class are allowed to take as much time as needed on their final exam. The exact amount of time it takes each student to finish the final exam is an example of a discrete random variable continuous random variablearrow_forward4 No three in a row You are given n balls arranged in a row. Each ball i has a value v;. Give a polynomial time algorithm to pick a maxi- mum value subset S of the balls so that no three consecutive balls are in S. For example, say the ball values are 2 2 3 2 2 then, the maximum value subset has the first, second, fourth and the fifth ball, and their total value is 2+2+ 2+2 = 8. For this problem, you also need to write a proof of correctness of the recurrence.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr