Randomized algorithms. Inge Li Gørtz
|
|
- Kevin Kelley
- 5 years ago
- Views:
Transcription
1 Randomized algorithms Inge Li Gørtz
2 Randomized algorithms Today What are randomized algorithms? Properties of randomized algorithms Two examples: Median/Select. Quick-sort
3 Randomized Algorithms
4 Randomized Algorithms So far we dealt with deterministic algorithms: Giving the same input to the algorithm repeatedly results in: The same running time. The same output. Randomized algorithm: Can make random choices (using a random number generator)
5 Random number generator A randomized algorithm has access to a random number generator rand(a, b), where a, b are integers, a < b. rand(a, b) returns a number x {a, (a + 1),..., (b 1), b}. Each of the b a + 1 numbers is equally likely. Calling rand(a, b) again results in a new, possibly different number. rand(a, b) has no memory. The current number does not depend on the results of previous calls. Statistically speaking: rand(a, b) generates numbers independently according to uniform distribution.
6 Randomized algorithms The algorithm can make random decisions using rand Running while (rand(0,1) = 0) do print( running ); end while print( stopped ); Julefrokost while (rand(1,4) = rand(1,4)) do have another Christmas beer; end while go home;
7 Properties of randomized algorithms A randomized algorithm might never stop. Example: Find the position of 7 in a three-element array containing the numbers 4, 3 and 7. Find7(A[1 3]) goon := true; while (goon) do i := rand(1,3); if (A[i] = 7) then print(bingo: 7 found at position i); goon := false; end if end while
8 Properties of randomized algorithms A randomized algorithm might find the wrong solution. Example: Find the position of the minimum element in a three-element array. MinOfThree(A[1 3]) i := rand(1,3); j := rand(1,3); return(min(a[i],a[j]); If A = [5,6,4] and i = 2 and j = 1 then the algorithm will wrongly return 5.
9 Properties of randomized algorithms Both examples are not so bad as they look. It is highly unlikely that Find7 runs a long time. It is more likely that MinOfThree returns a correct result than a wrong one.
10 Events An event is something that can happen. An atomic event is not composed of others. Each atomic event x has an associated probability P[x] [0,1]. The sum of the probabilities of all atomic events is 1. X x is atomic event P [x] =1 We consider only finite or countably infinite sets of atomic events.
11 Random variables A random variable is an entity that can assume different values. The values are selected randomly ; i.e., the process is governed by a probability distribution. Examples: The number shown by a die. The distance of two coins dropped on the floor. The running time of a randomized algorithm.
12 Expected values Let X be a random variable with values in {x1, xn}, where xi are numbers. Let pi = P[X = xi] be the probability that X assumes value xi. The expected value (expectation) of X is defined as E[X] = x i p i i=1 The expectation is the theoretical average.
13 Example: a fair die Let X be the random variable number shown by the die. Atomic events: {1, 2, 3, 4, 5, 6} Probabilities: P[1] = = P[6] = 1/6 Composed event: Even = {2, 4, 6} Composed event: ge4 = {4, 5, 6} Expectation: E[X] = ( )/6 = 3.5
14 Example: a loaded die Let X be the random variable number shown by the die. Atomic events: 1, 2, 3, 4, 5, 6 Probabilities: 0.1, 0.1, 0.1, 0.3, 0.2, 0.2 Expectation E[X] = = 4.0
15 Expectation If we repeatedly perform independent trials of an experiment, each of which succeeds with probability p > 0, then the expected number of trails we need to perform until the first succes is 1/p. Linearity of expectation: For two random variables X and Y we have E[X+Y] = E[X] + E[Y].
16 Rules for Probabilities Let A and B be events. If A and B are independent then P[A B] = P[A] P[B] If A and B are disjoint then P[A B] = P[A] + P[B]
17 Independence example A die is tossed twice. Let the random variable X1 be the result of first throw. Let the random variable X2 be the result of second throw. Events: A = (X1 = 2) and B = (X2 = 5) P[A] = 1/6 and P[B] = 1/6 P[A B] = 1/36 = 1/6 1/6 = P[A] P[B]
18 Non-independent example Event A = Even = {2, 4, 6}: P[A] = 1/2 Event B = ge4 = {4, 5, 6}: P[B] = 1/2 A B = {4, 6} P[A B] = 1/3 1/4 = P[A] P[B]
19 Analysis of MinOfThree MinOfThree(A[1 3]) i := rand(1,3); j := rand(1,3); return(min(a[i],a[j]); Running time: O(1). What is the chance that the answer of MinOfThree is correct? 9 possible pairs all with probability 1/9: (1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3) Assume wlog that A[1] is the minimum: 5 of the 9 pairs contain the index 1 and give the correct minimum. P[correct] = 5/9 > 1/2.
20 Analysis of MinOfThree MinOfThree(A[1 3]) i := rand(1,3); j := rand(1,3); return(min(a[i],a[j]); Running MinOfThree once gives the correct answer with probaility 5/9 and the incorrect one with probability 4/9. Idea: Run MinOfThree many times and pick the smallest value returned. The probability that MinOfThree fails every time in k runs is: To be 99% sure to find the minimum, choose k such that
21 Analysis of Find7 Find7(A[1 3]) goon := true; while (goon) do i := rand(1,3); if (A[i] = 7) then print(bingo: 7 found at position i); goon := false; end if end while Running time is variable. What is the expected running time? Assume wlog that A[1] = 7. If rand(1, 3) = 1 then the while-loop is terminated. P[rand(1,3) = 1] = 1/3 If rand(1, 3) 1 then the while-loop is not terminated. P[rand(1,3) 1] = 2/3 The while-loop is terminated after one iteration with probability P[rand(1,3) = 1] = 1/3.
22 Analysis of Find7 Find7(A[1 3]) goon := true; while (goon) do i := rand(1,3); if (A[i] = 7) then print(bingo: 7 found at position i); goon := false; end if end while The while-loop stops after exactly two iterations if rand(1, 3) 1 in the first iteration. rand(1, 3) = 1 in the second iteration. This happens with probability 2/3 and 1/3, resp. The probability for both to happen is - by independence -
23 Analysis of Find7 The while-loop stops after exactly three iterations if rand(1, 3) 1 in the first two iterations. rand(1, 3) = 1 in the third iteration. This happens with probability 2/3, 2/3 and 1/3, resp. The probability for all three to happen is - by independence - The while-loop stops after exactly k iterations if rand(1, 3) 1 in the first k-1 iterations. rand(1, 3) = 1 in the kth iteration. This happens with probability 2/3, 2/3 and 1/3, resp. The probability for all three to happen is - by independence -
24 Expected running time We have The expected running time of Find7 is Idea: Stop Las Vegas algorithm if it runs much longer than the expected time and restart it.
25 Types of randomized algorithms We have seen two kinds of algorithms: Monte Carlo algorithms: stop after a fixed (polynomial) time and give the correct answer with probability greater 50%. Las Vegas algorithms: have variable running time but always give the correct answer.
26 Median/Select
27 Select Given n numbers S = {a1, a2,, an}. Median: number that is in the middle position if in sorted order. Select(S,k): Return the kth smallest number in S. Min(S) = Select(S,1), Max(S)= Select(S,n), Median = Select(S,n/2). Assume the numbers are distinct. Select(S, k) { } Choose a pivot s S uniformly at random. For each element e in S if e < s put e in S if e > s put e in S if S = k-1 then return s if S k then call Select(S, k) if S < k then call Select(S, k - S - 1)
28 Select Select(S, k) { } Choose a pivot s S uniformly at random. For each element e in S if e < s put e in S if e > s put e in S if S = k-1 then return s if S k then call Select(S, k) if S < k then call Select(S, k - S - 1) Worst case running time: T (n) =cn + c(n 1) + c(n 2) + = (n 2 ). If there is at least an Limit number of bad pivots. " fraction of elements both larger and smaller than s: T (n) = cn +(1 ")cn +(1 ") 2 cn + = 1+(1 ")+(1 ") 2 + cn apple cn/". Intuition: A fairly large fraction of elements are well-centered => random pivot likely to be good.
29 Select Phase j: Size of set at most and at least. Element is central if at least a quarter of the elements in the current call are smaller and at least a quarter are larger. At least half the elements are central. Pivot central => size of set shrinks with by at least a factor 3/4 => current phase ends. Pr[s is central] = 1/2. Expected number of iterations before a central pivot is found = 2 => expected number of iterations in phase j at most 2. X: random variable equal to number of steps taken by algorithm. Xj: expected number of steps in phase j. X = X1+ X2 +. Number of steps in one iteration in phase j is at most cn(3/4) j. E[Xj] = 2cn(3/4) j. Expected running time: E[X] = X j n(3/4) j n(3/4) j+1 E[X j ] apple X j 2cn j 3 =2cn X 4 j j 3 apple 8cn. 4
30 Quicksort
31 Quicksort Given n numbers S = {a1, a2,, an} return the sorted list. Assume the numbers are distinct. Quicksort(A,p,r) { if S 1 return S else Choose a pivot s S uniformly at random. For each element e in S if e < s put e in S if e > s put e in S L = Quicksort(S ) R = Quicksort(S ) } Return the sorted list L s R.
32 Quicksort: Analysis Worst case Quicksort requires Ω(n 2 ) comparisons: if pivot is the smallest element in the list in each recursive call. If pivot aways is the median then T(n) = O(n log n). for i < j: random variable ( 1 if a i and a j compared by algorithm X ij = 0 otherwise X total number of comparisons: 1 X = i=1 j=i+1 X ij Expected number of comparisons: 1 E[X] =E[ X ij ]= i=1 j=i+1 1 i=1 j=i+1 E[X ij ]
33 Quicksort: Analysis Expected number of comparisons: 1 E[X] =E[ X ij ]= i=1 j=i+1 1 i=1 j=i+1 E[X ij ] Since Xij only takes values 0 and 1: E[X ij ]=Pr[X ij = 1] ai and aj compared iff ai or aj is the first pivot chosen from Zij = {ai,,aj}. Pivot chosen independently uniformly at random => all elements from Zij equally likely to be chosen as first pivot from this set. We have Thus Pr[X ij = 1] = 2/(j i + 1) E[X] = 1 i=1 j=i+1 E[X ij ] = 1 i=1 j=i+1 Pr[X ij ] = 1 i=1 j=i+1 2 j i +1 = 1 i=1 i+1 k=2 2 k < 1 i=1 k=1 2 k = 1 i=1 O(log n) = O(n log n)
34 Programming Competition Prize for best three teams. Can count as a mandatory assignment.
Random Variable. Pr(X = a) = Pr(s)
Random Variable Definition A random variable X on a sample space Ω is a real-valued function on Ω; that is, X : Ω R. A discrete random variable is a random variable that takes on only a finite or countably
More informationIntroduction to Randomized Algorithms: Quick Sort and Quick Selection
Chapter 14 Introduction to Randomized Algorithms: Quick Sort and Quick Selection CS 473: Fundamental Algorithms, Spring 2011 March 10, 2011 14.1 Introduction to Randomized Algorithms 14.2 Introduction
More informationAn Introduction to Randomized algorithms
An Introduction to Randomized algorithms C.R. Subramanian The Institute of Mathematical Sciences, Chennai. Expository talk presented at the Research Promotion Workshop on Introduction to Geometric and
More informationAlgorithms, CSE, OSU Quicksort. Instructor: Anastasios Sidiropoulos
6331 - Algorithms, CSE, OSU Quicksort Instructor: Anastasios Sidiropoulos Sorting Given an array of integers A[1... n], rearrange its elements so that A[1] A[2]... A[n]. Quicksort Quicksort(A, p, r) if
More informationLecture 4. Quicksort
Lecture 4. Quicksort T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2018 Networking
More informationAlgorithms And Programming I. Lecture 5 Quicksort
Algorithms And Programming I Lecture 5 Quicksort Quick Sort Partition set into two using randomly chosen pivot 88 31 25 52 14 98 62 30 23 79 14 31 2530 23 52 88 62 98 79 Quick Sort 14 31 2530 23 52 88
More informationQuicksort (CLRS 7) We previously saw how the divide-and-conquer technique can be used to design sorting algorithm Merge-sort
Quicksort (CLRS 7) We previously saw how the divide-and-conquer technique can be used to design sorting algorithm Merge-sort Partition n elements array A into two subarrays of n/2 elements each Sort the
More informationDivide and conquer. Philip II of Macedon
Divide and conquer Philip II of Macedon Divide and conquer 1) Divide your problem into subproblems 2) Solve the subproblems recursively, that is, run the same algorithm on the subproblems (when the subproblems
More informationAnalysis of Algorithms CMPSC 565
Analysis of Algorithms CMPSC 565 LECTURES 38-39 Randomized Algorithms II Quickselect Quicksort Running time Adam Smith L1.1 Types of randomized analysis Average-case analysis : Assume data is distributed
More informationExtended Algorithms Courses COMP3821/9801
NEW SOUTH WALES Extended Algorithms Courses Aleks Ignjatović School of Computer Science and Engineering University of New South Wales rithms What are we going to do in this class We will do: randomised
More informationAnalysis of Algorithms. Randomizing Quicksort
Analysis of Algorithms Randomizing Quicksort Randomizing Quicksort Randomly permute the elements of the input array before sorting OR... modify the PARTITION procedure At each step of the algorithm we
More informationCS161: Algorithm Design and Analysis Recitation Section 3 Stanford University Week of 29 January, Problem 3-1.
CS161: Algorithm Design and Analysis Recitation Section 3 Stanford University Week of 29 January, 2018 Problem 3-1. (Quicksort Median-of-3 Partition) One way to improve the randomized quicksort procedure
More informationCSCI 3110 Assignment 6 Solutions
CSCI 3110 Assignment 6 Solutions December 5, 2012 2.4 (4 pts) Suppose you are choosing between the following three algorithms: 1. Algorithm A solves problems by dividing them into five subproblems of half
More informationBucket-Sort. Have seen lower bound of Ω(nlog n) for comparisonbased. Some cheating algorithms achieve O(n), given certain assumptions re input
Bucket-Sort Have seen lower bound of Ω(nlog n) for comparisonbased sorting algs Some cheating algorithms achieve O(n), given certain assumptions re input One example: bucket sort Assumption: input numbers
More informationCMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015
CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015 1 Introduction The divide-and-conquer strategy is a general paradigm for algorithm design. This strategy
More informationCSE 525 Randomized Algorithms & Probabilistic Analysis Spring Lecture 3: April 9
CSE 55 Randomized Algorithms & Probabilistic Analysis Spring 01 Lecture : April 9 Lecturer: Anna Karlin Scribe: Tyler Rigsby & John MacKinnon.1 Kinds of randomization in algorithms So far in our discussion
More informationRandomization in Algorithms
Randomization in Algorithms Randomization is a tool for designing good algorithms. Two kinds of algorithms Las Vegas - always correct, running time is random. Monte Carlo - may return incorrect answers,
More informationFundamental Algorithms
Chapter 2: Sorting, Winter 2018/19 1 Fundamental Algorithms Chapter 2: Sorting Jan Křetínský Winter 2018/19 Chapter 2: Sorting, Winter 2018/19 2 Part I Simple Sorts Chapter 2: Sorting, Winter 2018/19 3
More informationFundamental Algorithms
Fundamental Algorithms Chapter 2: Sorting Harald Räcke Winter 2015/16 Chapter 2: Sorting, Winter 2015/16 1 Part I Simple Sorts Chapter 2: Sorting, Winter 2015/16 2 The Sorting Problem Definition Sorting
More informationCSE 421, Spring 2017, W.L.Ruzzo. 8. Average-Case Analysis of Algorithms + Randomized Algorithms
CSE 421, Spring 2017, W.L.Ruzzo 8. Average-Case Analysis of Algorithms + Randomized Algorithms 1 outline and goals 1) Probability tools you've seen allow formal definition of "average case" running time
More informationLecture 2: Randomized Algorithms
Lecture 2: Randomized Algorithms Independence & Conditional Probability Random Variables Expectation & Conditional Expectation Law of Total Probability Law of Total Expectation Derandomization Using Conditional
More informationRandomized Algorithms
Randomized Algorithms Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Basics A new 4 credit unit course Part of Theoretical Computer Science courses at the Department of Mathematics There will be 4 hours
More informationData Structures and Algorithm Analysis (CSC317) Randomized Algorithms (part 3)
Data Structures and Algorithm Analysis (CSC317) Randomized Algorithms (part 3) Quicksort p r Quicksort(A, p, r) 1. If p
More informationAbout complexity. We define the class informally P in the following way:
About complexity We define the class informally P in the following way: P = The set of all problems that can be solved by a polynomial time algorithm, i.e., an algorithm that runs in time O(n k ) in the
More informationTheorem 1.7 [Bayes' Law]: Assume that,,, are mutually disjoint events in the sample space s.t.. Then Pr( )
Theorem 1.7 [Bayes' Law]: Assume that,,, are mutually disjoint events in the sample space s.t.. Then Pr Pr = Pr Pr Pr() Pr Pr. We are given three coins and are told that two of the coins are fair and the
More informationData Structures and Algorithm Analysis (CSC317) Randomized algorithms
Data Structures and Algorithm Analysis (CSC317) Randomized algorithms Hiring problem We always want the best hire for a job! Using employment agency to send one candidate at a time Each day, we interview
More information1 Quick Sort LECTURE 7. OHSU/OGI (Winter 2009) ANALYSIS AND DESIGN OF ALGORITHMS
OHSU/OGI (Winter 2009) CS532 ANALYSIS AND DESIGN OF ALGORITHMS LECTURE 7 1 Quick Sort QuickSort 1 is a classic example of divide and conquer. The hard work is to rearrange the elements of the array A[1..n]
More informationCSE 312, Winter 2011, W.L.Ruzzo. 8. Average-Case Analysis of Algorithms + Randomized Algorithms
CSE 312, Winter 2011, W.L.Ruzzo 8. Average-Case Analysis of Algorithms + Randomized Algorithms 1 insertion sort Array A[1]..A[n] for i = 1..n-1 { T = A[i] Sorted j swap j = i-1 compare while j >= 0 &&
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Chapter 2 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: Room 5326, Engineering Building, Thursday 4:30pm -
More informationCS145: Probability & Computing Lecture 24: Algorithms
CS145: Probability & Computing Lecture 24: Algorithms Instructor: Eli Upfal Brown University Computer Science Figure credits: Bertsekas & Tsitsiklis, Introduction to Probability, 2008 Pitman, Probability,
More informationDivide and Conquer Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 14
Divide and Conquer Algorithms CSE 101: Design and Analysis of Algorithms Lecture 14 CSE 101: Design and analysis of algorithms Divide and conquer algorithms Reading: Sections 2.3 and 2.4 Homework 6 will
More informationAlgorithms Test 1. Question 1. (10 points) for (i = 1; i <= n; i++) { j = 1; while (j < n) {
Question 1. (10 points) for (i = 1; i
More informationLecture 5: Two-point Sampling
Randomized Algorithms Lecture 5: Two-point Sampling Sotiris Nikoletseas Professor CEID - ETY Course 2017-2018 Sotiris Nikoletseas, Professor Randomized Algorithms - Lecture 5 1 / 26 Overview A. Pairwise
More informationQuicksort. Where Average and Worst Case Differ. S.V. N. (vishy) Vishwanathan. University of California, Santa Cruz
Quicksort Where Average and Worst Case Differ S.V. N. (vishy) Vishwanathan University of California, Santa Cruz vishy@ucsc.edu February 1, 2016 S.V. N. Vishwanathan (UCSC) CMPS101 1 / 28 Basic Idea Outline
More informationTopic 4 Randomized algorithms
CSE 103: Probability and statistics Winter 010 Topic 4 Randomized algorithms 4.1 Finding percentiles 4.1.1 The mean as a summary statistic Suppose UCSD tracks this year s graduating class in computer science
More information1. [10 marks] Consider the following two algorithms that find the two largest elements in an array A[1..n], where n >= 2.
CSC 6 H5S Homework Assignment # 1 Spring 010 Worth: 11% Due: Monday February 1 (at class) For each question, please write up detailed answers carefully. Make sure that you use notation and terminology
More informationReview of Probability. CS1538: Introduction to Simulations
Review of Probability CS1538: Introduction to Simulations Probability and Statistics in Simulation Why do we need probability and statistics in simulation? Needed to validate the simulation model Needed
More informationIndependence. P(A) = P(B) = 3 6 = 1 2, and P(C) = 4 6 = 2 3.
Example: A fair die is tossed and we want to guess the outcome. The outcomes will be 1, 2, 3, 4, 5, 6 with equal probability 1 6 each. If we are interested in getting the following results: A = {1, 3,
More informationAn analogy from Calculus: limits
COMP 250 Fall 2018 35 - big O Nov. 30, 2018 We have seen several algorithms in the course, and we have loosely characterized their runtimes in terms of the size n of the input. We say that the algorithm
More informationThe probability of an event is viewed as a numerical measure of the chance that the event will occur.
Chapter 5 This chapter introduces probability to quantify randomness. Section 5.1: How Can Probability Quantify Randomness? The probability of an event is viewed as a numerical measure of the chance that
More informationb + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d
CS161, Lecture 4 Median, Selection, and the Substitution Method Scribe: Albert Chen and Juliana Cook (2015), Sam Kim (2016), Gregory Valiant (2017) Date: January 23, 2017 1 Introduction Last lecture, we
More informationThe space complexity of approximating the frequency moments
The space complexity of approximating the frequency moments Felix Biermeier November 24, 2015 1 Overview Introduction Approximations of frequency moments lower bounds 2 Frequency moments Problem Estimate
More informationAbout complexity. Number theoretical algorithms
Page 1 About complexity We define the class informally P in the following way: P = The set of all problems that can be solved by a polynomial time algorithm, i.e., an algorithm that runs in time O(n k
More informationLecture 4: Two-point Sampling, Coupon Collector s problem
Randomized Algorithms Lecture 4: Two-point Sampling, Coupon Collector s problem Sotiris Nikoletseas Associate Professor CEID - ETY Course 2013-2014 Sotiris Nikoletseas, Associate Professor Randomized Algorithms
More informationExpectation of geometric distribution
Expectation of geometric distribution What is the probability that X is finite? Can now compute E(X): Σ k=1f X (k) = Σ k=1(1 p) k 1 p = pσ j=0(1 p) j = p 1 1 (1 p) = 1 E(X) = Σ k=1k (1 p) k 1 p = p [ Σ
More informationData Structures and Algorithms
Data Structures and Algorithms Spring 2017-2018 Outline 1 Sorting Algorithms (contd.) Outline Sorting Algorithms (contd.) 1 Sorting Algorithms (contd.) Analysis of Quicksort Time to sort array of length
More informationExpectation of geometric distribution. Variance and Standard Deviation. Variance: Examples
Expectation of geometric distribution Variance and Standard Deviation What is the probability that X is finite? Can now compute E(X): Σ k=f X (k) = Σ k=( p) k p = pσ j=0( p) j = p ( p) = E(X) = Σ k=k (
More informationQuick Sort Notes , Spring 2010
Quick Sort Notes 18.310, Spring 2010 0.1 Randomized Median Finding In a previous lecture, we discussed the problem of finding the median of a list of m elements, or more generally the element of rank m.
More informationLecture 10. Sublinear Time Algorithms (contd) CSC2420 Allan Borodin & Nisarg Shah 1
Lecture 10 Sublinear Time Algorithms (contd) CSC2420 Allan Borodin & Nisarg Shah 1 Recap Sublinear time algorithms Deterministic + exact: binary search Deterministic + inexact: estimating diameter in a
More informationOutline. 1 Introduction. 3 Quicksort. 4 Analysis. 5 References. Idea. 1 Choose an element x and reorder the array as follows:
Outline Computer Science 331 Quicksort Mike Jacobson Department of Computer Science University of Calgary Lecture #28 1 Introduction 2 Randomized 3 Quicksort Deterministic Quicksort Randomized Quicksort
More informationCS 580: Algorithm Design and Analysis
CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Announcements: Homework 6 deadline extended to April 24 th at 11:59 PM Course Evaluation Survey: Live until 4/29/2018
More informationSolutions. Problem 1: Suppose a polynomial in n of degree d has the form
Assignment 1 1. Problem 3-1 on p. 57 2. Problem 3-2 on p. 58 3. Problem 4-5 on p. 86 4. Problem 6-1 on p. 142 5. Problem 7-4 on p. 162 6. Prove correctness (including halting) of SelectionSort (use loop
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Lecture 6-8 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments
More informationCSE 613: Parallel Programming. Lecture 9 ( Divide-and-Conquer: Partitioning for Selection and Sorting )
CSE 613: Parallel Programming Lecture 9 ( Divide-and-Conquer: Partitioning for Selection and Sorting ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Spring 2012 Parallel Partition
More informationCSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019
CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis
More informationSimulation Modeling. Random Numbers
Mathematical Modeling Lia Vas Simulation Modeling. Random Numbers In many cases one of the following situations might occur: - It is not possible to observe the behavior directly or to conduct experiments.
More informationSorting Algorithms. We have already seen: Selection-sort Insertion-sort Heap-sort. We will see: Bubble-sort Merge-sort Quick-sort
Sorting Algorithms We have already seen: Selection-sort Insertion-sort Heap-sort We will see: Bubble-sort Merge-sort Quick-sort We will show that: O(n log n) is optimal for comparison based sorting. Bubble-Sort
More informationCSE 548: Analysis of Algorithms. Lectures 18, 19, 20 & 21 ( Randomized Algorithms & High Probability Bounds )
CSE 548: Analysis of Algorithms Lectures 18, 19, 20 & 21 ( Randomized Algorithms & High Probability Bounds ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Fall 2012 Markov s Inequality
More informationSorting. Chapter 11. CSE 2011 Prof. J. Elder Last Updated: :11 AM
Sorting Chapter 11-1 - Sorting Ø We have seen the advantage of sorted data representations for a number of applications q Sparse vectors q Maps q Dictionaries Ø Here we consider the problem of how to efficiently
More informationCIS 121 Data Structures and Algorithms with Java Spring Big-Oh Notation Monday, January 22/Tuesday, January 23
CIS 11 Data Structures and Algorithms with Java Spring 018 Big-Oh Notation Monday, January /Tuesday, January 3 Learning Goals Review Big-Oh and learn big/small omega/theta notations Discuss running time
More informationSelection and Adversary Arguments. COMP 215 Lecture 19
Selection and Adversary Arguments COMP 215 Lecture 19 Selection Problems We want to find the k'th largest entry in an unsorted array. Could be the largest, smallest, median, etc. Ideas for an n lg n algorithm?
More informationIntroduction and basic definitions
Chapter 1 Introduction and basic definitions 1.1 Sample space, events, elementary probability Exercise 1.1 Prove that P( ) = 0. Solution of Exercise 1.1 : Events S (where S is the sample space) and are
More informationSequential Decisions
Sequential Decisions A Basic Theorem of (Bayesian) Expected Utility Theory: If you can postpone a terminal decision in order to observe, cost free, an experiment whose outcome might change your terminal
More informationDiscrete Probability
MAT 258 Discrete Mathematics Discrete Probability Kenneth H. Rosen and Kamala Krithivasan Discrete Mathematics 7E Global Edition Chapter 7 Reproduced without explicit consent Fall 2016 Week 11 Probability
More informationSample Spaces, Random Variables
Sample Spaces, Random Variables Moulinath Banerjee University of Michigan August 3, 22 Probabilities In talking about probabilities, the fundamental object is Ω, the sample space. (elements) in Ω are denoted
More informationDivide and Conquer Strategy
Divide and Conquer Strategy Algorithm design is more an art, less so a science. There are a few useful strategies, but no guarantee to succeed. We will discuss: Divide and Conquer, Greedy, Dynamic Programming.
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 5 - Jan. 12, 2018 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. 1 /
More informationRandomized Sorting Algorithms Quick sort can be converted to a randomized algorithm by picking the pivot element randomly. In this case we can show th
CSE 3500 Algorithms and Complexity Fall 2016 Lecture 10: September 29, 2016 Quick sort: Average Run Time In the last lecture we started analyzing the expected run time of quick sort. Let X = k 1, k 2,...,
More informationData Structures and Algorithms CSE 465
Data Structures and Algorithms CSE 465 LECTURE 8 Analyzing Quick Sort Sofya Raskhodnikova and Adam Smith Reminder: QuickSort Quicksort an n-element array: 1. Divide: Partition the array around a pivot
More informationAverage Case Analysis. October 11, 2011
Average Case Analysis October 11, 2011 Worst-case analysis Worst-case analysis gives an upper bound for the running time of a single execution of an algorithm with a worst-case input and worst-case random
More informationFast Sorting and Selection. A Lower Bound for Worst Case
Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 0 Fast Sorting and Selection USGS NEIC. Public domain government image. A Lower Bound
More informationQuicksort algorithm Average case analysis
Quicksort algorithm Average case analysis After today, you should be able to implement quicksort derive the average case runtime of quick sort and similar algorithms Q1-3 For any recurrence relation in
More informationSo far we discussed random number generators that need to have the maximum length period.
So far we discussed random number generators that need to have the maximum length period. Even the increment series has the maximum length period yet it is by no means random How do we decide if a generator
More informationLecture 2 Sep 5, 2017
CS 388R: Randomized Algorithms Fall 2017 Lecture 2 Sep 5, 2017 Prof. Eric Price Scribe: V. Orestis Papadigenopoulos and Patrick Rall NOTE: THESE NOTES HAVE NOT BEEN EDITED OR CHECKED FOR CORRECTNESS 1
More informationAdvanced Algorithms (2IL45)
Technische Universiteit Eindhoven University of Technology Course Notes Fall 2013 Advanced Algorithms (2IL45) Mark de Berg Contents 1 Introduction to randomized algorithms 4 1.1 Some probability-theory
More informationCentral Algorithmic Techniques. Iterative Algorithms
Central Algorithmic Techniques Iterative Algorithms Code Representation of an Algorithm class InsertionSortAlgorithm extends SortAlgorithm { void sort(int a[]) throws Exception { for (int i = 1; i < a.length;
More informationU.C. Berkeley CS174: Randomized Algorithms Lecture Note 12 Professor Luca Trevisan April 29, 2003
U.C. Berkeley CS174: Randomized Algorithms Lecture Note 12 Professor Luca Trevisan April 29, 2003 Fingerprints, Polynomials, and Pattern Matching 1 Example 1: Checking Matrix Multiplication Notes by Alistair
More informationLecture 1: Asymptotics, Recurrences, Elementary Sorting
Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running
More informationLecture 1. ABC of Probability
Math 408 - Mathematical Statistics Lecture 1. ABC of Probability January 16, 2013 Konstantin Zuev (USC) Math 408, Lecture 1 January 16, 2013 1 / 9 Agenda Sample Spaces Realizations, Events Axioms of Probability
More informationCryptography and Security Midterm Exam
Cryptography and Security Midterm Exam Solution Serge Vaudenay 25.11.2015 duration: 1h45 no documents allowed, except one 2-sided sheet of handwritten notes a pocket calculator is allowed communication
More informationRecap: Prefix Sums. Given A: set of n integers Find B: prefix sums 1 / 86
Recap: Prefix Sums Given : set of n integers Find B: prefix sums : 3 1 1 7 2 5 9 2 4 3 3 B: 3 4 5 12 14 19 28 30 34 37 40 1 / 86 Recap: Parallel Prefix Sums Recursive algorithm Recursively computes sums
More informationDivide-and-conquer. Curs 2015
Divide-and-conquer Curs 2015 The divide-and-conquer strategy. 1. Break the problem into smaller subproblems, 2. recursively solve each problem, 3. appropriately combine their answers. Known Examples: Binary
More informationProblem Set 2 Solutions
Introduction to Algorithms October 1, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Piotr Indyk and Charles E. Leiserson Handout 9 Problem Set 2 Solutions Reading: Chapters 5-9,
More informationProblem 1: (Chernoff Bounds via Negative Dependence - from MU Ex 5.15)
Problem 1: Chernoff Bounds via Negative Dependence - from MU Ex 5.15) While deriving lower bounds on the load of the maximum loaded bin when n balls are thrown in n bins, we saw the use of negative dependence.
More information11.1 Set Cover ILP formulation of set cover Deterministic rounding
CS787: Advanced Algorithms Lecture 11: Randomized Rounding, Concentration Bounds In this lecture we will see some more examples of approximation algorithms based on LP relaxations. This time we will use
More informationModule 1: Analyzing the Efficiency of Algorithms
Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?
More informationCS 573: Algorithmic Game Theory Lecture date: January 23rd, 2008
CS 573: Algorithmic Game Theory Lecture date: January 23rd, 2008 Instructor: Chandra Chekuri Scribe: Bolin Ding Contents 1 2-Player Zero-Sum Game 1 1.1 Min-Max Theorem for 2-Player Zero-Sum Game....................
More information14.1 Finding frequent elements in stream
Chapter 14 Streaming Data Model 14.1 Finding frequent elements in stream A very useful statistics for many applications is to keep track of elements that occur more frequently. It can come in many flavours
More informationReview Of Topics. Review: Induction
Review Of Topics Asymptotic notation Solving recurrences Sorting algorithms Insertion sort Merge sort Heap sort Quick sort Counting sort Radix sort Medians/order statistics Randomized algorithm Worst-case
More informationDef :Corresponding to an underlying experiment, we associate a probability with each ω Ω, Pr{ ω} Pr:Ω [0..1] such that Pr{ω} = 1
Read : GKP 8.1,8.2 Quicksort is the sorting technique of choice although its worst-case behavior is inferior to that of many others. Why? What does average case mean? Seeking a phone number (which exists)
More informationRecap of Basic Probability Theory
02407 Stochastic Processes Recap of Basic Probability Theory Uffe Høgsbro Thygesen Informatics and Mathematical Modelling Technical University of Denmark 2800 Kgs. Lyngby Denmark Email: uht@imm.dtu.dk
More informationDiscrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14
CS 70 Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14 Introduction One of the key properties of coin flips is independence: if you flip a fair coin ten times and get ten
More information(x 1 +x 2 )(x 1 x 2 )+(x 2 +x 3 )(x 2 x 3 )+(x 3 +x 1 )(x 3 x 1 ).
CMPSCI611: Verifying Polynomial Identities Lecture 13 Here is a problem that has a polynomial-time randomized solution, but so far no poly-time deterministic solution. Let F be any field and let Q(x 1,...,
More informationMAT Mathematics in Today's World
MAT 1000 Mathematics in Today's World Last Time We discussed the four rules that govern probabilities: 1. Probabilities are numbers between 0 and 1 2. The probability an event does not occur is 1 minus
More informationCSCE 750 Final Exam Answer Key Wednesday December 7, 2005
CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note
More informationEnumerate all possible assignments and take the An algorithm is a well-defined computational
EMIS 8374 [Algorithm Design and Analysis] 1 EMIS 8374 [Algorithm Design and Analysis] 2 Designing and Evaluating Algorithms A (Bad) Algorithm for the Assignment Problem Enumerate all possible assignments
More informationRecap of Basic Probability Theory
02407 Stochastic Processes? Recap of Basic Probability Theory Uffe Høgsbro Thygesen Informatics and Mathematical Modelling Technical University of Denmark 2800 Kgs. Lyngby Denmark Email: uht@imm.dtu.dk
More informationN/4 + N/2 + N = 2N 2.
CS61B Summer 2006 Instructor: Erin Korber Lecture 24, 7 Aug. 1 Amortized Analysis For some of the data structures we ve discussed (namely hash tables and splay trees), it was claimed that the average time
More informationIntroduction to Probability 2017/18 Supplementary Problems
Introduction to Probability 2017/18 Supplementary Problems Problem 1: Let A and B denote two events with P(A B) 0. Show that P(A) 0 and P(B) 0. A A B implies P(A) P(A B) 0, hence P(A) 0. Similarly B A
More informationLecture 1: Probability Fundamentals
Lecture 1: Probability Fundamentals IB Paper 7: Probability and Statistics Carl Edward Rasmussen Department of Engineering, University of Cambridge January 22nd, 2008 Rasmussen (CUED) Lecture 1: Probability
More information