CPSC 335 Randomized Algorithms Dr. Marina Gavrilova Computer Science University of Calgary Canada.

Slides:



Advertisements
Similar presentations
Comp 122, Spring 2004 Order Statistics. order - 2 Lin / Devi Comp 122 Order Statistic i th order statistic: i th smallest element of a set of n elements.
Advertisements

Sublinear Algorithms … Lecture 23: April 20.
Introduction to Algorithms Quicksort
Foundations of Cryptography Lecture 10 Lecturer: Moni Naor.
CSCI 3160 Design and Analysis of Algorithms Tutorial 4
Order Statistics Sorted
QuickSort Average Case Analysis An Incompressibility Approach Brendan Lucier August 2, 2005.
Algorithms Analysis Lecture 6 Quicksort. Quick Sort Divide and Conquer.
Theory of Computing Lecture 3 MAS 714 Hartmut Klauck.
CPSC 335 Dynamic Programming Dr. Marina Gavrilova Computer Science University of Calgary Canada.
WS Algorithmentheorie 03 – Randomized Algorithms (Primality Testing) Prof. Dr. Th. Ottmann.
1 Today’s Material Medians & Order Statistics – Ch. 9.
CSE 2331/5331 Topic 5: Prob. Analysis Randomized Alg.
Randomized Algorithms Randomized Algorithms CS648 Lecture 6 Reviewing the last 3 lectures Application of Fingerprinting Techniques 1-dimensional Pattern.
Analysis of Algorithms CS 477/677 Randomizing Quicksort Instructor: George Bebis (Appendix C.2, Appendix C.3) (Chapter 5, Chapter 7)
Updated QuickSort Problem From a given set of n integers, find the missing integer from 0 to n using O(n) queries of type: “what is bit[j]
WS Algorithmentheorie 03 – Randomized Algorithms (Overview and randomised Quicksort) Prof. Dr. Th. Ottmann.
1 Introduction to Randomized Algorithms Md. Aashikur Rahman Azim.
CS 253: Algorithms Chapter 7 Mergesort Quicksort Credit: Dr. George Bebis.
Ch. 7 - QuickSort Quick but not Guaranteed. Ch.7 - QuickSort Another Divide-and-Conquer sorting algorithm… As it turns out, MERGESORT and HEAPSORT, although.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 4 Comparison-based sorting Why sorting? Formal analysis of Quick-Sort Comparison.
CSE 830: Design and Theory of Algorithms
Tirgul 8 Universal Hashing Remarks on Programming Exercise 1 Solution to question 2 in theoretical homework 2.
Randomized Algorithms Prof. Dr. Th. Ottmann University of Freiburg
COMP305. Part II. Genetic Algorithms. Genetic Algorithms.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Data Structures Review Session 1
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
11 -1 Chapter 11 Randomized Algorithms Randomized algorithms In a randomized algorithm (probabilistic algorithm), we make some random choices.
Ch. 8 & 9 – Linear Sorting and Order Statistics What do you trade for speed?
10 Algorithms in 20th Century Science, Vol. 287, No. 5454, p. 799, February 2000 Computing in Science & Engineering, January/February : The Metropolis.
Randomized Algorithms (Probabilistic algorithm) Flip a coin, when you do not know how to make a decision!
Stochastic Algorithms Some of the fastest known algorithms for certain tasks rely on chance Stochastic/Randomized Algorithms Two common variations – Monte.
Randomized Turing Machines
Chapter 14 Randomized algorithms Introduction Las Vegas and Monte Carlo algorithms Randomized Quicksort Randomized selection Testing String Equality Pattern.
Order Statistics The ith order statistic in a set of n elements is the ith smallest element The minimum is thus the 1st order statistic The maximum is.
1 Lecture 16: Lists and vectors Binary search, Sorting.
11 -1 Chapter 11 Randomized Algorithms Randomized Algorithms In a randomized algorithm (probabilistic algorithm), we make some random choices.
CS 61B Data Structures and Programming Methodology July 28, 2008 David Sun.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Computation Model and Complexity Class. 2 An algorithmic process that uses the result of a random draw to make an approximated decision has the ability.
Greedy Methods and Backtracking Dr. Marina Gavrilova Computer Science University of Calgary Canada.
Algorithms & FlowchartsLecture 10. Algorithm’s CONCEPT.
Sorting Data Structures and Algorithms (60-254). Sorting Sorting is one of the most well-studied problems in Computer Science The ultimate reference on.
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
Umans Complexity Theory Lectures Lecture 7b: Randomization in Communication Complexity.
RSA cryptosystem--preview Suppose n=p  q and  (n)=(p-1)(q-1), where p and q are big primes. Select (find) a and b, such that a  b=1 mod  (n). K=(n,p,q,a,b),
Instructor Neelima Gupta Expected Running Times and Randomized Algorithms Instructor Neelima Gupta
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.
QuickSort Choosing a Good Pivot Design and Analysis of Algorithms I.
CS 615: Design & Analysis of Algorithms Chapter 7: Randomized Algorithms (Weiss Chap.: 10.4)
Analysis of Algorithms Spring semester 2002 Uri Zwick
Quicksort This is probably the most popular sorting algorithm. It was invented by the English Scientist C.A.R. Hoare It is popular because it works well.
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.
Rabin & Karp Algorithm. Rabin-Karp – the idea Compare a string's hash values, rather than the strings themselves. For efficiency, the hash value of the.
Advanced Algorithms Analysis and Design
CMPT 120 Topic: Searching – Part 1
Lecture 8 Randomized Algorithms
Rabin & Karp Algorithm.
Objective of This Course
Data Structures Review Session
Probabilistic algorithms
An Analysis of Quicksort:
Probabilistic algorithms
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
Presentation transcript:

CPSC 335 Randomized Algorithms Dr. Marina Gavrilova Computer Science University of Calgary Canada

 A randomized algorithm can be defined as one that receives, in addition to its input, a stream of random bits that it can use in the course of its action for the purpose of making random choices.  A randomized algorithm may give different results when applied to the same input in different runs. Randomized Algorithm

 There are two main advantages of randomized algorithms: - First, often the execution time or space requirement is smaller than that of the best deterministic algorithm. - Second, randomized algorithms are extremely simple to comprehend and implement. Advantages of Randomized Algorithm

 Las Vegas algorithms: constitute those randomized algorithms that always give a correct solution, or do not have any correct solutionat all.  Monte Carlo Algorithms: These algorithms always give an answer, but may occasionally produce an answer that is incorrect. Types of Randomized Algorithm

 If A is a randomized algorithm, then its running time on a fixed instance I of size n may vary from one execution to another.  Therefore, a more natural measure of performance is the expected running time of A on a fixed instance I.  This is the mean time taken by algorithm A to solve the instance I over and over. Thus, it is natural to talk about the worst case expected time and the average case expected time. Computational Complexity of A Randomized Algorithm

 The running time of quicksort is on the average, provided that all permutations of the input elements are equally likely. This is not the case in many applications. If the input is already sorted, then its running time is Randomized Quicksort

 One approach to guarantee a running time of on the average is to introduce a preprocessing step with purpose to permute the elements to be sorted randomly. This step can be performed in time. Randomized Quicksort  Another approach is to introduce an element of randomness into the algorithm. This can be done by selecting the pivot on which to split the elements randomly. The result of choosing the pivot randomly is to relax the assumption that all permutations of the input elements are equally likely.

Randomized Quicksort

 Randomized Las Vegas algorithm Expected running time - Randomized Selection

 Theorem: The expected number of elements comparisons performed by Algorithm RANDOMIZEDSELECT on input of size n is less than 4n. Its expected running time is. Randomized Selection

 Let two parties A and B communicate over a reliable communication channel.  They want to determine whether x = y, x and y are two long strings of A and B respectively.  Cost of using the channel – extremely expensive.  Another alternative – A derives much shorter string (serve as a ‘ fingerprint ’ ) from x and send it to B. B follows the same procedure.  If they are equal, B conclude that x = y Testing String Equality

 One method of fingerprinting is to choose a prime number p and then use the fingerprint function - I p (x) = I (x) (mod p).  The number of bits transmitted is thus smaller. If, then obviously,. The converse is also true. If I p (x) = I p (y), then it is not necessarily the case that x = y. Testing String Equality

 The wellness of this method is that, for fixed p, there are certain pair of strings x and y on which the method will always fail.  To get around this problem of the existence of these pairs x and y – chose p at random every time the equality of two strings is to be checked, rather than agree on p in advance. Testing String Equality

 Given a string of text X= x 1 x 2 … x n and a pattern Y= y 1 y 2 … y m, where, determine whether or not the pattern appears in the text.  The most straightforward method for solving this problem is to move the pattern across the entire text, and in every position compare the pattern with the portion of the text of length m. This Brute-force method leads to an O(mn) running time in the worst case. More complicated deterministic algorithms have running time O(m+n). Pattern Matching

 Running time is O(m+n).  Follows the same Brute-force algorithm, but instead of comparing the pattern with each block X(j)=x j x j+1 … x j+m-1, this algorithm compare the fingerprint I p (Y) of the pattern with the fingerprints I p (X(j)) of the blocks of text.  The key observation is that, when one block of text is shifted to the next, the fingerprint of the new block X(j+1) can easily be computed from the fingerprint of X(j). Monte Carlo Algorithm for Pattern Matching

Pattern Matching

 M. E. Dyer and A. M. Frieze, A randomized algorithm for fixed-dimensional linear programming, Joural of Mathematical Programming, vol.44, no. 1- 3,May,  V. V. Patel, G. Deodhare and T. Viswanath, Some applications of randomized algorithms for control system design, Automatica,vol. 38, no. 12, Dcember References

Define Las Vegas and Monte Carlo algorithms Explain how randomized pattern matching works Describe testing string equality algorithm Describe randomized quicksort method 19 Review questions

Thank You