Randomized Algorithms Tutorial 3 Hints for Homework 2.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms Quicksort
Advertisements

Size-estimation framework with applications to transitive closure and reachability Presented by Maxim Kalaev Edith Cohen AT&T Bell Labs 1996.
QuickSort Average Case Analysis An Incompressibility Approach Brendan Lucier August 2, 2005.
Theory of Computing Lecture 3 MAS 714 Hartmut Klauck.
Using Divide and Conquer for Sorting
CSL758 Instructors: Naveen Garg Kavitha Telikepalli Scribe: Manish Singh Vaibhav Rastogi February 7 & 11, 2008.
© 2004 Goodrich, Tamassia Quick-Sort     29  9.
© 2004 Goodrich, Tamassia QuickSort1 Quick-Sort     29  9.
WS Algorithmentheorie 03 – Randomized Algorithms (Overview and randomised Quicksort) Prof. Dr. Th. Ottmann.
1 Sorting Problem: Given a sequence of elements, find a permutation such that the resulting sequence is sorted in some order. We have already seen: –Insertion.
Quick-Sort     29  9.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
1 Algorithms for Large Data Sets Ziv Bar-Yossef Lecture 12 June 18, 2006
Probabilistic (Average-Case) Analysis and Randomized Algorithms Two different but similar analyses –Probabilistic analysis of a deterministic algorithm.
1 Algorithms for Large Data Sets Ziv Bar-Yossef Lecture 8 May 4, 2005
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 4 Comparison-based sorting Why sorting? Formal analysis of Quick-Sort Comparison.
Randomized Computation Roni Parshani Orly Margalit Eran Mantzur Avi Mintz
Prof. Bart Selman Module Probability --- Part d)
Probability Distributions
© 2004 Goodrich, Tamassia Sorting Lower Bound1. © 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms.
The Goldreich-Levin Theorem: List-decoding the Hadamard code
© 2004 Goodrich, Tamassia Selection1. © 2004 Goodrich, Tamassia Selection2 The Selection Problem Given an integer k and n elements x 1, x 2, …, x n, taken.
1 CSC401 – Analysis of Algorithms Lecture Notes 9 Radix Sort and Selection Objectives  Introduce no-comparison-based sorting algorithms: Bucket-sort and.
Analysis of Algorithms CS 477/677
Selection1. 2 The Selection Problem Given an integer k and n elements x 1, x 2, …, x n, taken from a total order, find the k-th smallest element in this.
Sorting Lower Bound1. 2 Comparison-Based Sorting (§ 4.4) Many sorting algorithms are comparison based. They sort by making comparisons between pairs of.
Ch. 8 & 9 – Linear Sorting and Order Statistics What do you trade for speed?
Algorithms 2005 Ramesh Hariharan.
The Selection Problem. 2 Median and Order Statistics In this section, we will study algorithms for finding the i th smallest element in a set of n elements.
Sorting Fun1 Chapter 4: Sorting     29  9.
Analysis of Algorithms CS 477/677
Introduction to Algorithms Jiafen Liu Sept
Week11 Parameter, Statistic and Random Samples A parameter is a number that describes the population. It is a fixed number, but in practice we do not know.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Chapter 9: Selection Order Statistics What are an order statistic? min, max median, i th smallest, etc. Selection means finding a particular order statistic.
Randomized Algorithms CSc 4520/6520 Design & Analysis of Algorithms Fall 2013 Slides adopted from Dmitri Kaznachey, George Mason University and Maciej.
© 2001 by Charles E. Leiserson Introduction to AlgorithmsDay 12 L8.1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 8 Prof. Charles E. Leiserson.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Average Case Analysis.
Skip Lists 二○一七年四月二十五日
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 7.
Week 121 Law of Large Numbers Toss a coin n times. Suppose X i ’s are Bernoulli random variables with p = ½ and E(X i ) = ½. The proportion of heads is.
ICS 353: Design and Analysis of Algorithms
NP-Completness Turing Machine. Hard problems There are many many important problems for which no polynomial algorithms is known. We show that a polynomial-time.
1 Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
Chapter 6 Large Random Samples Weiqi Luo ( 骆伟祺 ) School of Data & Computer Science Sun Yat-Sen University :
Sorting Lower Bounds n Beating Them. Recap Divide and Conquer –Know how to break a problem into smaller problems, such that –Given a solution to the smaller.
2.2 Discrete Random Variables 2.2 Discrete random variables Definition 2.2 –P27 Definition 2.3 –P27.
1 Chapter 8-1: Lower Bound of Comparison Sorts. 2 About this lecture Lower bound of any comparison sorting algorithm – applies to insertion sort, selection.
1 Chapter 7 Quicksort. 2 About this lecture Introduce Quicksort Running time of Quicksort – Worst-Case – Average-Case.
Chapter 11 Sorting Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and Mount.
Quick-Sort 2/18/2018 3:56 AM Selection Selection.
Streaming & sampling.
Quick-Sort 9/12/2018 3:26 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Quick-Sort 9/13/2018 1:15 AM Quick-Sort     2
Lecture 8 Randomized Algorithms
Selection Selection 1 Quick-Sort Quick-Sort 10/30/16 13:52
Quick-Sort 11/14/2018 2:17 PM Chapter 4: Sorting    7 9
COMS E F15 Lecture 2: Median trick + Chernoff, Distinct Count, Impossibility Results Left to the title, a presenter can insert his/her own image.
Quick-Sort 11/19/ :46 AM Chapter 4: Sorting    7 9
Quick-Sort 2/23/2019 1:48 AM Chapter 4: Sorting    7 9
Quick-Sort 2/25/2019 2:22 AM Quick-Sort     2
Quick-Sort 4/8/ :20 AM Quick-Sort     2 9  9
Tomado del libro Cormen
Tutorial 10: Limit Theorems
Quick-Sort 4/25/2019 8:10 AM Quick-Sort     2
Quick-Sort 5/7/2019 6:43 PM Selection Selection.
CS 583 Analysis of Algorithms
Quick-Sort 5/25/2019 6:16 PM Selection Selection.
Sorting We have actually seen already two efficient ways to sort:
Chapter 11 Sets, and Selection
Presentation transcript:

Randomized Algorithms Tutorial 3 Hints for Homework 2

Outline Hints for Homework 2 Randomized Quicksort (Exercise 4.20) Michael’s Algorithm (optional) [1] One of Three (optional) [1] [1]Probability and Computing, CMU , Fall 2007.

Hints for Homework 2

Exercise 1 Find variance in number of fixed points assuming permutation is chosen uniformly at random Hint  Cannot use linearity to find the variance.  Just calculate it directly

Exercise 2 Weak Law of Large Numbers  independent RV X 1, X 2, …, X n  Same finite mean μ, finite std-dev σ Show Hint  Chebyshev’s inequality

Exercise 3 (Parameter Estimation) Show that Show for any δ belongs to (0,1)

Exercise 4 Let X 1, X 2, …, X n be n Poisson trials Let a 1, a 2, …, a n be real in [0,1] Let W = Σ a i X i and ν=E[W]. Show that Hint  MGF & Markov inequality

Exercise 4 Somehow, you may need to show this inequality to simplify terms: For any x 2 [0,1], e tx – 1 · x(e t – 1) Hint: can be proven by calculus

Exercise 5 Let X = X 1 + X 2 + … + X n, each X i = Geo(0.5) Compare X with a sequence of fair coin tosses  Show that

Randomized Quicksort

Quicksort(S) { 1. If |S| ≦ 1, return S 2. Else, pick an item x from S 3. Divide S into S 1 and S 2 with S 1 = list of all items smaller than x S 2 = list of all items greater than x 4. List 1 = Quicksort(S 1 ) 5. List 2 = Quicksort(S 2 ) 6. return List 1, x, List 2 }

Randomized Quicksort In step 2, we choose x by picking an item uniformly at random from S. Runtime = expected O(n log n) Can we show it runs in O(n log n) time with high probability ?

Randomized Quicksort Let s = size of the set to be sorted at a particular node Node:= point which decides on a pivot

Randomized Quicksort …………………… s/23s/4 good nodebad node A good node is one whose pivot divides the set into two parts with size of each part not exceeding 2s/3

Randomized Quicksort Fact 1: # good nodes in any path is at most c log 2 n, for some c Proof: # good nodes is at most log n / log(3/2) = c log n

Randomized Quicksort Fact 2: With probability ≧ 1 - 1/n 2, # nodes in a root-to-leaf path is at most c’ log 2 n, for some c’ Proof: P := a root-to-leaf path, l := length of P B := # bad nodes in P

Randomized Quicksort Proof (cont.): Now, we know that B ≧ l – c log n (why?) and Pr(bad node) = 2/3 Pr(l > c’ log n) ≦ Pr(B > c’ log n – c log n) ≦ (2/3) c’ log n – c log n < n -2 ( for large c’ )

Randomized Quicksort Fact 3: With probability ≧ 1-1/n, # nodes in the longest root-to-leaf path is at most c’ log 2 n Proof: Union Bound

Randomized Quicksort Conclusion: Runtime of Randomized Quicksort is O(n log n) with prob at least 1-1/n Proof: Height of the tree is O(log n) with probability at least 1-1/n Runtime in this case: O(n log n)

Michael’s Algorithm

Input: a set of 2D points Determine the closest pair (and its dist) Input points are stored in an array …

Michael’s Algorithm Suppose we have a strange storage data structure D : When we give a point to D, it stores the point and outputs the closest pair of points stored in D D Output Insert D Output

Michael’s Algorithm Our knowledge: Insertion time depends on whether the closest pair is changed or not. If output is the same: 1 clock tick D Output Insert D Output

Michael’s Algorithm If output is not the same: |D| clock ticks Insert D Output D

Michael’s Algorithm With random insertion order, show that the expected total number of clock ticks used by D is O(n) Proof: X i : # clock ticks to insert i th point X: the total clock ticks

Michael’s Algorithm Proof (cont.): p = Pr( i th point causes answer change) = Pr( i th point causes answer change) = 2/i  E[X i ] = i*p + 1*(1-p) = i* 2/i +1- 2/i < 3  E[X] = O(n) by linearity of expectation

One of Three

A company is developing a prediction system by machine learning For a given item, the prediction has  Pr(success) = p 1  Pr(failure) = p 2  Pr(not sure) = p 3

One of Three The algorithm is run for n items Let X 1 : total # with correct prediction X 2 : total # with failure prediction X 3 : total # with not-sure prediction Can we compute E[X 1 |X 3 =m] ?

One of Three Answer: (1) X 3 =m  X 1 +X 2 = n’ = n-m (2) Let p’ denote: Pr(i th prediction correct | not not-sure) = p 1 / (p 1 +p 2 )

One of Three The value of X 1 given X 3 =m is Bin(n’,p’) E[X 1 |X 3 =m] = n’p’ = (n-m)p 1 /(p 1 +p 2 )