1 / 35

Randomized Algorithms CS648

Randomized Algorithms CS648. Lecture 6 Reviewing the last 3 lectures Application of Fingerprinting Techniques 1-dimensional Pattern matching Preparation for the next lecture. Randomized Algorithms discussed till now. Randomized algorithm for Approximate Median Randomized Quick Sort

pembroke
Download Presentation

Randomized Algorithms CS648

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Randomized AlgorithmsCS648 Lecture 6 Reviewing the last 3 lectures Application of Fingerprinting Techniques 1-dimensional Pattern matching Preparation for the next lecture.

  2. Randomized Algorithms discussed till now • Randomized algorithm for Approximate Median • Randomized Quick Sort • Frievald’s algorithm for Matrix Product Verification • Randomized algorithm for Equality of two files Randomly select a sample Randomly permute the array Randomly select a vector Randomly select a prime number

  3. Randomized Algorithms How does one go about designing a randomized algorithm ?

  4. Randomized Algorithms Some random idea is required to design a randomized algorithm.

  5. Randomized Algorithms An idea based on insight into the problem Difficult/impossible to exploit the idea deterministically A randomized algorithm Randomization to materialize the idea

  6. Randomized Quick Sort

  7. Randomized Quick Sort Elements of A arranged in Increasing order of values … A pivot

  8. Randomized Quick Sort Observation: There are many elements in A that are good pivot. Is it possible to select one good pivot efficiently ? (not possible deterministically ) We select pivot element randomly uniformly. A randomly selected element is a good pivot with probability

  9. Randomized Algorithm for Approximate median

  10. Randomized Algorithm for Approximate median A sample captures the essence of the original population.

  11. Randomized Algorithm for Approximate median Idea: Is it possible to select a small subset of elements whose median approximates the median ? (not possible deterministically ) Median of auniformly random sample will be approximate median. A random sample captures the essenceof the original population.

  12. Frievald’s TechniqueApplication matrix product verification

  13. Frievald’sAlgorithm 0 0 0 0

  14. Frievald’sAlgorithmThe key idea Fact: An equation has a unique solution depending upon and only. Problem:Suppose you do not know the values of and . Your aim is to select a value for which does not satisfy the corresponding equation. Idea: Consider any two different values {,}. Surely the equation is not satisfied for at least one of {,}. Can we select that value deterministically ? selects a value randomly uniformly out of {,}. Randomization used to exploit the idea:

  15. Frievald’sAlgorithm(Analyzing error probability) 2 + … + = 0 Fixing the values of , …, arbitrarily + … + = 0

  16. FingerprintingApplication Cryptography

  17. Aim:To determine if File Aidentical to File Bby communicating fewest bits ? File A File B

  18. How many primes less than ?

  19. Key idea from prime Less than prime factors of around prime numbers in ]

  20. Visualize a file as a binary number File A = … File B = … = = Overview of Protocol: Let be a prime number selected randomly uniformly from [] If mod = mod then conclude A=B else conclude A≠B Error occurs if “isone of the prime factors of()”

  21. FingerprintingApplication 3 Pattern matching

  22. 17 100101100110001101111010101110101010111010000101 Text : Pattern : Pattern is said to appear in Text at location if for all . Problem: Given a Text , and a pattern , does appear anywhere in ? Deterministic Algorithm • Trivial algorithm: O() time • Knuth-Morris-Prattalgorithm: O() time Randomized Monte Carlo Algorithm • O() time, and error probability < 011110101011101

  23. Motivation • Simplicity, real time implementation, streaming environment • Extension to 2-dimensions • ConvertingMonte Carlo toLas Vegas algorithm 1 1 0 1 1 0 1 1 0 1 1 1 1 1 1 m⨯m n⨯n O() time algorithm

  24. Randomized Algorithm for Fingerprinting

  25. Checking ifappears in Text at location 100101100110001101111010101010101010111010000101 Text : Pattern : Observation: O() time algorithm is obvious. Question: How to do this task in O(1) time ? Answer: have a fingerprint . Question:What properties should the fingerprint possess? • ?? • ?? 0111101110110101 Small size Efficiently computable

  26. Checking ifappears in Text at location 100101100110001101111010101010101010111010000101 Text : Pattern : = = Let be a prime number selected randomly uniformly from [ ] mod . mod . Ifthen conclude that appears at. Error occurs if “isone of the prime factors of()” Error probability at location ≤ Fingerprint has size= O() bits. 0111101110110101 Small size but Not efficiently computable

  27. Checking ifappears in Text at location 100101100110001101111010101010101010111010000101 Text : Pattern : = = Question: Any relation between and ? Question: Any relation between and ? =  mod= ()mod • = ()mod • = ()mod 0111101110110101 <

  28. Fingerprint function: how good is it ? 100101100110001101111010101010101010111010000101 Text : Pattern : = mod = mod Lemma: The fingerprint function • Occupies bits. • Computing take O() bits operations. • Error probability for any particular location is . Question:What is the error probability of the algorithm ? 0111101110110101

  29. Bounding the error probability of the algorithm : event that the algorithm fails : event that the fingerprint shows a false match at any fixed location Can you see some relation between and ’s ? = P() ≤ = sinceis the same for each . <=. Question:How large should be to ensure P() < Answer: = ()  Fingerprint size: O().

  30. Final result Theorem: There is a Monte Carlo randomized algorithm for detecting any match of P[] in T[] that : • Fails with error probability <. • Performs O() operations involving O() bit numbers. Homework: It is possible to convert the above algorithm to Las Vagas. Spend some time thinking over it (we shall discuss it in some class). It takes O(1) time on word-RAM model of computation for an operation involving O()bit numbers. So the time complexity of the algorithm is O()

  31. Probability tool (union theorem) Suppose there is an event defined over a probability space (,P). Aim: to get an upper bound on P(). If it is difficult to calculate P(), try to express as union of events (usually similar/same)such that • it is easy to calculate P() Then you may bound P() using the following inequality: P() ≤

  32. Applications of the Union Theorem

  33. Balls into Bins 1 2 3 4 5 … m-1 m Ball-bin Experiment: There are balls and bins. Each ball selects its bin randomly uniformly and independent of other balls and falls into it. Used in: • Hashing • Load balancing in distributed environment 1 2 3 … i … n

  34. Balls into Bins 1 2 3 4 5 … m-1 m Ball-bin Experiment: There are balls and bins. Each ball selects its bin randomly uniformly and independent of other balls and falls into it. Theorem: For the case when , prove that with very high probability, every bin has O(log) balls. (The proof requires Union theorem and elementary probability. We shall discuss it in the next class. Spend some time to prove it on your own.) 1 2 3 … i … n

  35. Randomized Quick sort Theorem: Probability that Randomized Quick sort performs more than logcomparisons is less than . Tools needed: • Union theorem • Probability that we get less than HEADS during tosses of a fair coin is less than . (The proof requires Union theorem and elementary probability. We shall discuss it in the next class. Spend some time to prove it on your own.)

More Related