Concept explainers
The Monty Hall Paradox. Marilyn vos Savant described the following problem (loosely based on a game show hosted by Monty Hall) in a popular magazine: “Suppose you’re on a game show, and you’re given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what’s behind the doors, opens another door, say No. 3, which has a goat. He then says to you, “Do you want to pick door No. 2?” Is it to your advantage to switch your choice?”
Ms. vos Savant proved that it is to your advantage, but many of her readers, including some mathematics professors, disagreed, arguing that the probability would not change because another door was opened.
Your task is to simulate this game show. In each iteration, randomly pick a door number between 1 and 3 for placing the car. Randomly have the player pick a door. Randomly have the game show host pick a door having a goat (but not the door that the player picked). Increment a counter for strategy 1 if the player wins by switching to the host’s choice, and increment a counter for strategy 2 if the player wins by sticking with the original choice. Run 1,000 iterations and print both counters.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Data Mining for Business Analytics: Concepts, Techniques, and Applications with XLMiner
Software Engineering (10th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- Write a program using Python to solve the locker riddle which reads as follows: Imagine 100 lockers numbered 1 to 100 with 100 students lined up in front of those 100lockers:The first student opens every locker.The second student closes every 2nd locker.The 3rd student changes every 3rd locker; if it’s closed, she opens it; if it’s open, she closes it.The 4th student changes every fourth locker (e.g., 4th, 8th, etc.).The 5th student changes every 5th locker (e.g., 5th, 10th, etc.).That same pattern continues for all 100 students. Which lockers are left open after all 100 students have walked the rowof lockers?arrow_forward1.Implement Thirsty problem using semaphore . Scenario:To drink, a thirsty person must have three things; water, ice and a glass.There are three thirsty people, each having a different one (and only one) of the three required items. A fourth person, a server has unlimited supply of all three items. If nobody is drinking, the server places two of the three items (chosen at random) onto table. Thirsty person who can make a drink from those two items will pick them up and drink a glass of ice water. When done, thirsty person will notify the server and the process will repeat.arrow_forwardA chess knight, on one turn, moves either two squares vertically and one horizontally, or two horizontally and one vertically. If we consider a knight starting at the point ⟨x, y⟩ in Z × Z, it has eight possible moves, to ⟨x+1,y+2⟩,⟨x+1,y−2⟩,⟨x−1,y+2⟩,⟨x−1,y−2⟩,⟨x+ 2, y + 1⟩, ⟨x + 2, y − 1⟩, ⟨x − 2, y + 1⟩, or⟨x − 2, y − 1⟩. (a) Prove that given any two points ⟨x, y⟩ and ⟨x′, y′⟩ in Z × Z, there is a sequence of knight moves from the first point to the second. (b) Let a and b be different positive naturals. An (a, b)-knight also has eight possible moves, from ⟨x,y⟩ to ⟨x±a,y±b⟩ or ⟨x±b,y±a⟩. What conditions on a and b allow the (a, b)-knight to go from any point in Z × Z to any other? Prove your answer. (c) If a and b do not meet the conditions of part (b), exactly which points can the (a,b)- knight reach from ⟨x, y⟩arrow_forward
- comment what each line does in the programarrow_forwardjava-matlabarrow_forwardShrek has guessed three positive integers a, b, and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: a + b, a+ c, b + c and a+b+c. You have to guess three numbers a, b, and c using given numbers. Print three guessed integers in any order. Pay attention that some given numbers a, b and c can be equal (it is also possible that a-b=c). Instruction: Create a Java program that will perform the algorithm that will solve the problem using inheritance as shown in the figure. It must satisfy the 3-sample output as shown below. Explain your codes using comments. Main class Creates an instance of "Number" class and call the methods. in Input sequence as shown in the figure. numl, num2, num3, num4 :int ● Main Input class - It contains a method in() that ask four positive integers for the numbers on the board in…arrow_forward
- Write a program that plays the tic-tac-toe game. Two players take turns clicking an available cell in a grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical,or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the cells in the grid have been filled with tokens and neither player has achieved a win. Figure 12.17 shows the representative sample runs of the example. Assume that all the cells are initially empty, and that the first player takes the X token and the second player the O token. To mark a cell, the player points the mouse to the cell and clicks it. If the cell is empty, the token (X or O) is displayed. If the cell is already filled, the player’s action is ignored.Define a custom class named Cell that extends Label for displaying a token and for responding to the button-click event. The class contains a data field token with three possible values—' ', X, and…arrow_forwardA variation of the classic Dining Philosophers problem is the one where the philosophers get a "ticket", i.e. a number that identifies their priority. The philosophers are supposed to eat based on this priority, e.g. if the last one to dine had a ticket value of 7, then the next one to be allowed to dine, regardless if he has to wait for the release of one or two forks, is the one with a ticket value of 8. Each philosopher is supposed to go through the following sequence of actions: think () getTicket () getForks () eat () releaseForks () : should be implemented in a monitor : replace with a random delay in [0, 1]sec : should be implemented in a monitor : should be implemented in a monitor : replace with a random delay in [0, 1]sec You program should be able to work for a variable number of philosophers that are specified in the command-line. E.g. $ ./deli 10 should run the program for 10 philosophers. Your output should be similar to the following: Philosopher 1 got ticket 0…arrow_forwardThe puzzle called the Towers of Hanoi consists of three pegs, one of which contains several rings stacked in order of descending diameter from bottom to top. The problem is to move the stack of rings to another peg. You are allowed to move only one ring at a time, and at no time is a ring to be placed on top of a smaller one. Observe that if the puzzle involved only one ring, it would be extremely easy. Moreover, when faced with the problem of moving several rings, if you could move all but the largest ring to another peg, the largest ring could then be placed on the third peg, and then the problem would be to move the remaining rings on top of it. Using this observation, develop a recursive algorithm for solving the Towers of Hanoi puzzle for an arbitrary number of rings.arrow_forward
- The Game of Master Mind is performed in the following way:Each of the computer's four slots will hold a ball that is either red (R), yellow (Y), green (G), or blue (B). The computer may have the following configuration: RGGB (Slot #1 is red, Slots #2 and #3 are green, and Slot #4 is blue).The user is making an educated guess at the answer. For instance, you may assume YRGB.You receive a bonus when you predict the right colour for the right slot "hit:' You receive an if you choose a colour that is real but is in the incorrect slot "pseudo-hit:' Keep in mind that a hit slot can never also qualify as a pseudo-hit.For example, if the actual solution is RGBY and you guess GGRR, you have one hit and one pseudohitWrite a method that, given a guess and a solution, returns the number of hits and pseudo-hitsarrow_forwardComputer Graphicsarrow_forwardFour mathematicians have a conversation, as follows: ALICE: I am insane. BOB: I am pure. CHARLES: I am applied. DOROTHY: I am sane. ALICE: Charles is pure. BOB: Dorothy is insane. CHARLES: Bob is applied. DOROTHY: Charles is sane. You are also given the following information: Pure mathematicians tell the truth about their beliefs. Applied mathematicians lie about their beliefs. Sane mathematicians' beliefs are correct. Insane mathematicians' beliefs are incorrect. With the preceding clues, classify the four mathematicians as applied or pure, and insane or sane. Briefly explain your logic.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrOperations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole