CS 787: Advanced Algorithms Homework 1

Similar documents
Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 13

CSC/MTH 231 Discrete Structures II Spring, Homework 5

I. WHAT IS PROBABILITY?

The topic for the third and final major portion of the course is Probability. We will aim to make sense of statements such as the following:

Dependence. Math Circle. October 15, 2016

The next several lectures will be concerned with probability theory. We will aim to make sense of statements such as the following:

1. An office building contains 27 floors and has 37 offices on each floor. How many offices are in the building?

The Teachers Circle Mar. 20, 2012 HOW TO GAMBLE IF YOU MUST (I ll bet you $5 that if you give me $10, I ll give you $20.)

Bell Work. Warm-Up Exercises. Two six-sided dice are rolled. Find the probability of each sum or 7

1. The chance of getting a flush in a 5-card poker hand is about 2 in 1000.

Discrete Structures for Computer Science

1. A factory makes calculators. Over a long period, 2 % of them are found to be faulty. A random sample of 100 calculators is tested.

Foundations of Computing Discrete Mathematics Solutions to exercises for week 12

CS1802 Week 9: Probability, Expectation, Entropy

The study of probability is concerned with the likelihood of events occurring. Many situations can be analyzed using a simplified model of probability

PROBABILITY. 1. Introduction. Candidates should able to:

MATH 215 DISCRETE MATHEMATICS INSTRUCTOR: P. WENG

S = {(1, 1), (1, 2),, (6, 6)}

Checkpoint Questions Due Monday, October 7 at 2:15 PM Remaining Questions Due Friday, October 11 at 2:15 PM

8.2 Union, Intersection, and Complement of Events; Odds

Contemporary Mathematics Math 1030 Sample Exam I Chapters Time Limit: 90 Minutes No Scratch Paper Calculator Allowed: Scientific

Section Summary. Finite Probability Probabilities of Complements and Unions of Events Probabilistic Reasoning

Conditional Probability Worksheet

Name. Is the game fair or not? Prove your answer with math. If the game is fair, play it 36 times and record the results.

Probability MAT230. Fall Discrete Mathematics. MAT230 (Discrete Math) Probability Fall / 37

Grade 6 Math Circles Fall Oct 14/15 Probability

NAME : Math 20. Midterm 1 July 14, Prof. Pantone

Conditional Probability Worksheet

Midterm 2 Practice Problems

Chapter 8: Probability: The Mathematics of Chance

ACM International Collegiate Programming Contest 2010

Probability. March 06, J. Boulton MDM 4U1. P(A) = n(a) n(s) Introductory Probability

The Chinese Remainder Theorem

CSE 21 Practice Final Exam Winter 2016

Lecture 7: The Principle of Deferred Decisions

Details of Play Each player counts out a number of his/her armies for initial deployment, according to the number of players in the game.

PROBABILITY M.K. HOME TUITION. Mathematics Revision Guides. Level: GCSE Foundation Tier

Introduction to Counting and Probability

MAT104: Fundamentals of Mathematics II Summary of Counting Techniques and Probability. Preliminary Concepts, Formulas, and Terminology

KS3 Levels 3-8. Unit 3 Probability. Homework Booklet. Complete this table indicating the homework you have been set and when it is due by.

Math 4610, Problems to be Worked in Class

1 2-step and other basic conditional probability problems

Raise your hand if you rode a bus within the past month. Record the number of raised hands.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Mathematical Foundations HW 5 By 11:59pm, 12 Dec, 2015

Probability --QUESTIONS-- Principles of Math 12 - Probability Practice Exam 1

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand HW 8

Eleventh Annual Ohio Wesleyan University Programming Contest April 1, 2017 Rules: 1. There are six questions to be completed in four hours. 2.

Junior Circle Meeting 5 Probability. May 2, ii. In an actual experiment, can one get a different number of heads when flipping a coin 100 times?

Part 1: I can express probability as a fraction, decimal, and percent

18.S34 (FALL, 2007) PROBLEMS ON PROBABILITY

Functional Skills Mathematics

1.5 How Often Do Head and Tail Occur Equally Often?

1 2-step and other basic conditional probability problems

Math : Probabilities

RANDOM EXPERIMENTS AND EVENTS

Multiplication and Probability

Lecture 2: Sum rule, partition method, difference method, bijection method, product rules

Probability. Misha Lavrov. ARML Practice 5/5/2013

GCSE MATHEMATICS Intermediate Tier, topic sheet. PROBABILITY

CSC/MATA67 Tutorial, Week 12

Compound Probability. Set Theory. Basic Definitions

The Chinese Remainder Theorem

, x {1, 2, k}, where k > 0. (a) Write down P(X = 2). (1) (b) Show that k = 3. (4) Find E(X). (2) (Total 7 marks)

Theory of Probability - Brett Bernstein

Week 1: Probability models and counting

Section Introduction to Sets

Choose one person to be the immune system (IM player). All the other players are pathogens (P players).


Name Date. Sample Spaces and Probability For use with Exploration 12.1

Independent Events B R Y

Math 1070 Sample Exam 2

MEP Practice Book SA5

University of Connecticut Department of Mathematics

Design and Analysis of Information Systems Topics in Advanced Theoretical Computer Science. Autumn-Winter 2011

Game Playing Part 1 Minimax Search

Lesson 4: Calculating Probabilities for Chance Experiments with Equally Likely Outcomes

(a) Suppose you flip a coin and roll a die. Are the events obtain a head and roll a 5 dependent or independent events?

Selected Game Examples

MEP Practice Book ES5. 1. A coin is tossed, and a die is thrown. List all the possible outcomes.

COCI 2017/2018. Round #1, October 14th, Tasks. Task Time limit Memory limit Score. Cezar 1 s 64 MB 50. Tetris 1 s 64 MB 80

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 11

3 PROBABILITY TOPICS

Probability Rules. 2) The probability, P, of any event ranges from which of the following?

MC215: MATHEMATICAL REASONING AND DISCRETE STRUCTURES

Probability Paradoxes

Lesson 4: Calculating Probabilities for Chance Experiments with Equally Likely Outcomes

Simulations. 1 The Concept

2.5 Sample Spaces Having Equally Likely Outcomes

CSE 312 Midterm Exam May 7, 2014

Due Friday February 17th before noon in the TA drop box, basement, AP&M. HOMEWORK 3 : HAND IN ONLY QUESTIONS: 2, 4, 8, 11, 13, 15, 21, 24, 27

2008 ACM ICPC Southeast USA Regional Programming Contest. 25 October, 2008 PROBLEMS

MAT 17: Introduction to Mathematics Final Exam Review Packet. B. Use the following definitions to write the indicated set for each exercise below:

Mathematical Magic Tricks

Intermediate Math Circles November 1, 2017 Probability I

INDEPENDENT AND DEPENDENT EVENTS UNIT 6: PROBABILITY DAY 2

MTH 103 H Final Exam. 1. I study and I pass the course is an example of a. (a) conjunction (b) disjunction. (c) conditional (d) connective

Math116Chapter15ProbabilityProbabilityDone.notebook January 08, 2012

A game by Marcel Süßelbeck and Marco Ruskowski for 2 4 players Parfum transports players to the wonderful world of fragrances, which dates.

If a regular six-sided die is rolled, the possible outcomes can be listed as {1, 2, 3, 4, 5, 6} there are 6 outcomes.

Transcription:

CS 787: Advanced Algorithms Homework 1 Out: 02/08/13 Due: 03/01/13 Guidelines This homework consists of a few exercises followed by some problems. The exercises are meant for your practice only, and do not have to be turned in. You are required to turn in the problems. We will provide solutions to all the questions. Some of the problems are difficult, so please get started early. Late submissions do not get any credit. Homework can be done in pairs. Please write your names clearly on your homework. Exercises 1. In the pattern matching problem you are given an n-bit string X and an m-bit pattern Y with m<<n. You need to determine whether Y is a substring of X, that is, if Y = X[j,,j+ m 1] for some j. Construct a randomized algorithm for this problem that runs in time O(m+n) and fails with probability at most 1/2. (Hint: Extend the communication protocol from Lecture 3.) 2. You are playing a game of chance but have lost the dice that come with it. Each move in the game depends on the sum of two standard dice rolls (that is, the sum of two independent numbers, each distributed uniformly at random between 1 and 6). You have a fair coin at your disposal. Using this coin you would like to simulate the distribution of the sum. Give a protocol for doing so that uses as few coin flips as possible to generate each draw of the sum. 3. Clock solitaire is played using a standard deck of 52 cards as follows. The deck is divided randomly into 13 piles of 4 cards each such that each card is equally likely to end up in any of the 13 4 positions. The piles are labeled A, 2, 3,,J,Q,K in an arbitrary manner. The game begins by picking the topmost card in the pile labeled A. At every subsequent step, the player picks the topmost card from the pile with the same label as the card previously picked. The game ends when either all the cards have been picked, or the player attempts to pick a card from an empty pile. In the former case, the player wins, and in the latter case she loses. Determine the probability that the player wins the game. 4. Consider flipping a fair coin n times and for i {1,,n} let S i denote the absolute difference between the number of heads and the number of tails observed in the first i flips. Let the discrepancy of the process denote the maximum such difference: D = max i S i. Prove that E[S i ]=O( i) and E[D] =O( n). Problems 1. Consider the following balls and bins process that proceeds in rounds. In the first round, we throw n balls independently and uniformly at random into n bins. At the end of each round, we discard every ball that fell into a bin by itself (that is, had no collisions). The remaining balls are retained for the next round, in which they are again thrown independently and uniformly at random into the n bins. Prove that this process takes O(log log n) steps in expectation. 2. Give a polynomial time algorithm for the attached ACM ICPC problem The Lost House. 1

3. Exploratory assingment 5.8 in the textbook (pp. 124 125). You should answer parts 1 and 2. For part 2, show that the number of nodes sent is N O(N 2/3 ) with constant probability. Part 3 is for extra credit. You do not need to turn in your code. You should use experiments to formulate hypotheses about what the answers should be, as well as, how to prove them. Your writeup should answer the problems with proofs, but you may also present supporting data and observations from your experiments. 2

3141 - The Lost House Asia - Beijing - 2004/2005 One day a snail climbed up to a big tree and finally came to the end of a branch. What a different feeling to look down from such a high place he had never been to before! However, he was very tired due to the long time of climbing, and fell asleep. An unbelievable thing happened when he woke up he found himself lying in a meadow and his house originally on his back disappeared! Immediately he realized that he fell off the branch when he was sleeping! He was sure that his house must still be on the branch he had been sleeping on. The snail began to climb the tree again, since he could not live without his house. When reaching the first fork of the tree, he sadly found that he could not remember the route that he climbed before. In order to find his lovely house, the snail decided to go to the end of every branch. It was dangerous to walk without the protection of the house, so he wished to search the tree in the best way. Fortunately, there lived many warm-hearted worms in the tree that could accurately tell the snail whether he had ever passed their places or not before he fell off. Now our job is to help the snail. We pay most of our attention to two parts of the tree the forks of the branches and the ends of the branches, which we call them key points because key events always happen there, such as choosing a path, getting the help from a worm and arriving at the house he is searching for. Assume all worms live at key points, and all the branches between two neighboring key points have the same distance of 1. The snail is now at the first fork of the tree. Our purpose is to find a proper route along which he can find his house as soon as possible, through the analysis of the structure of the tree and the locations of the worms. The only restriction on the route is that he must not go down from a fork until he has reached all the ends grown from this fork. The house may be left at the end of any branches in an equal probability. We focus on the mathematical expectation of the distance the snail has to cover before arriving his house. We wish the value to be as small as possible. As illustrated in Figure-1, the snail is at the key point 1 and his house is at a certain point among 2, 4 and 5. A worm lives at point 3, who can tell the snail whether his house is at one of point 4 and 5 or not. Therefore, the snail can choose two strategies. He can go to point 2 first. If he cannot find the house there, he should go back to point 1, and then reaches point 4 (or 5) by point 3. If still not, he has to return point 3, then go to point 5 (or 4), where he will undoubtedly find his house. In this choice, the snail covers distances of 1, 4, 6 corresponding to the circumstances under which the house is located at point 2, 4 (or 5), 5 (or 4) respectively. So the expectation value is (1 + 4 + 6) / 3 = 11 / 3. Obviously, this strategy does not make full use of the information from the worm. If the snail goes to point 3 and gets useful information from the worm first, and then chooses to go back to point 1 then towards point 2, or go to point 4 or 5 to take his chance, the distances he covers will be 2, 3, 4 corresponding to the different locations of the house. In such a strategy, the mathematical expectation will be (2 + 3 + 4) / 3 = 3, and it is the very route along which the snail should search the tree. 3141 - The Lost House 1/3

Input The input contains several sets of test data. Each set begins with a line containing one integer N, no more than 1000, which indicates the number of key points in the tree. Then follow N lines describing the N key points. For convenience, we number all the key points from 1 to N. The key point numbered with 1 is always the first fork of the tree. Other numbers may be any key points in the tree except the first fork. The i-th line in these N lines describes the key point with number i. Each line consists of one integer and one uppercase character 'Y' or 'N' separated by a single space, which represents the number of the previous key point and whether there lives a worm ('Y' means lives and 'N' means not). The previous key point means the neighboring key point in the shortest path between this key point and the key point numbered 1. In the above illustration, the previous key point of point 2 or 3 is point 1, while the previous key point of point 4 or 5 is point 3. This integer is -1 for the key point 1, means it has no previous key point. You can assume a fork has at most eight branches. The first set in the sample input describes the above illustration. A test case of N = 0 indicates the end of input, and should not be processed. Output Output one line for each set of input data. The line contains one float number with exactly four digits after the decimal point, which is the mathematical expectation value. Sample Input 5 10 3141 - The Lost House 2/3

3 Y 8 N 8 N 6 0 Sample Output 3.0000 5.0000 3.5000 Beijing 2004-2005 3141 - The Lost House 3/3