13. RANDOMIZED ALGORITHMS

Size: px
Start display at page:

Download "13. RANDOMIZED ALGORITHMS"

Transcription

1 Randomization Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Algorithmic design patterns. Greedy. Divide-and-conquer. Dynamic programming. Network flow. Randomization. Randomization. Allow fair coin flip in unit time. Why randomize? Can lead to simplest, fastest, or only known algorithm for a particular problem. in practice, access to a pseudo-random number generator Ex. Symmetry-breaking protocols, graph algorithms, quicksort, hashing, load balancing, Monte Carlo integration, cryptography. Last updated on 3/2/8 4:57 PM 2 Contention resolution in a distributed system Contention resolution. Given n processes P,, P n, each competing for access to a shared database. If two or more processes access the database simultaneously, all processes are locked out. Devise protocol to ensure all processes get through on a regular basis. Restriction. Processes can t communicate. Challenge. Need symmetry-breaking paradigm. P P 2... P n 4

2 Contention resolution: randomized protocol Contention resolution: randomized protocol Protocol. Each process requests access to the database at time t with probability p = /n. Claim. The probability that process i fails to access the database in en rounds is at most / e. After e n (c ln n) rounds, the probability n -c. Claim. Let S[i, t] = event that process i succeeds in accessing the database at time t. Then / (e n) Pr [S(i, t)] /(2n). Pf. By independence, Pr [S(i, t)] = p ( p) n. process i requests access none of remaining n- processes request access Pf. Let F[i, t] = event that process i fails to access database in rounds through t. By independence and previous claim, we have Pr [F[i, t]] ( /(en)) t. Choose t = e n : Pr[F(i, t)] ( en ) en $ % ( en) en e Setting p = /n, we have Pr [S(i, t)] = /n ( /n) n. value that maximizes Pr[S(i, t)] between /e and /2 Choose t = e n c ln n : Pr[F(i, t)] ( e ) c ln n = n c Useful facts from calculus. As n increases from 2, the function: ( /n) n - converges monotonically from /4 up to / e. ( /n) n converges monotonically from /2 down to / e. 5 6 Contention resolution: randomized protocol Claim. The probability that all processes succeed within 2e n ln n rounds is / n. Pf. Let F[t] = event that at least one of the n processes fails to access database in any of the rounds through t. [ ] = Pr F[i, t ] Pr F[t] " # $ n i= % &' Pr[ F[i, t]] n Choosing t = 2 en c ln n yields Pr[F[t]] n n -2 = / n. n i= union bound previous slide ( ) t en Union bound. Given events E,, E n, " n Pr # $ E i i= % &' n Pr[E i ] i= 7

3 Global minimum cut Contraction algorithm Global min cut. Given a connected, undirected graph G = (V, E), find a cut (A, B) of minimum cardinality. Applications. Partitioning items in a database, identify clusters of related documents, network reliability, network design, circuit design, TSP solvers. Network flow solution. Replace every edge (u, v) with two antiparallel edges (u, v) and (v, u). Pick some vertex s and compute min s- v cut separating s from each other vertex v V. False intuition. Global min-cut is harder than min s-t cut. Contraction algorithm. [Karger 995] Pick an edge e = (u, v) uniformly at random. Contract edge e. - replace u and v by single new super-node w - preserve edges, updating endpoints of u and v to w - keep parallel edges, but delete self-loops Repeat until graph has just two nodes u and v. Return the cut (all nodes that were contracted to form v ). a b c u d v contract u-v w f e a f b c 9 0 Contraction algorithm Contraction algorithm. [Karger 995] Pick an edge e = (u, v) uniformly at random. Contract edge e. - replace u and v by single new super-node w - preserve edges, updating endpoints of u and v to w - keep parallel edges, but delete self-loops Repeat until graph has just two nodes u and v. Return the cut (all nodes that were contracted to form v ). Contraction algorithm Claim. The contraction algorithm returns a min cut with prob 2 / n 2. Pf. Consider a global min-cut (A*, B*) of G. Let F* be edges with one endpoint in A* and the other in B*. Let k = F* = size of min cut. In first step, algorithm contracts an edge in F* probability k / E. Every node has degree k since otherwise (A*, B*) would not be a min-cut E ½ k n k / E 2 / n. Thus, algorithm contracts an edge in F* with probability 2 / n. A* B* F* Reference: Thore Husfeldt 2

4 Contraction algorithm Contraction algorithm Claim. The contraction algorithm returns a min cut with prob 2 / n 2. Pf. Consider a global min-cut (A*, B*) of G. Let F* be edges with one endpoint in A* and the other in B*. Let k = F* = size of min cut. Let Gʹ be graph after j iterations. There are nʹ = n j supernodes. Suppose no edge in F* has been contracted. The min-cut in Gʹ is still k. Since value of min-cut is k, Eʹ ½ k nʹ k / Eʹ 2 / nʹ. Thus, algorithm contracts an edge in F* with probability 2 / nʹ. Let E j = event that an edge in F* is not contracted in iteration j. Pr[E E 2! E n 2 ] = Pr[E ] Pr[E 2 E ]! Pr[E n 2 E E 2! E n 3 ] = ( 2 n) ( n 2 )! ( 2 4) ( 2 3) n 2 n 3 n n ( ) ( 3 ) ( ) ( )! 2 4 = 2 n(n ) 2 n 2 3 Amplification. To amplify the probability of success, run the contraction algorithm many times. Claim. If we repeat the contraction algorithm n 2 ln n times, then the probability of failing to find the global min-cut is / n 2. Pf. By independence, the probability of failure is at most # 2 & % $ n 2 ( ' n 2 lnn ) # = 2 & + % $ n 2 ( * + ' 2 n2,. -. 2ln n ( e ) 2lnn = n 2 ( /x) x /e with independent random choices, 4 Contraction algorithm: example execution Global min cut: context trial Remark. Overall running time is slow since we perform Θ(n 2 log n) iterations and each takes Ω(m) time. trial 2 trial 3 trial 4 Improvement. [Karger Stein 996] O(n 2 log 3 n). Early iterations are less risky than later ones: probability of contracting an edge in min cut hits 50% when n / 2 nodes remain. Run contraction algorithm until n / 2 nodes remain. Run contraction algorithm twice on resulting graph and return best of two cuts. trial 5 (finds min cut) Extensions. Naturally generalizes to handle positive weights. Best known. [Karger 2000] O(m log 3 n). trial 6 faster than best known max flow algorithm or deterministic global min cut algorithm... Reference: Thore Husfeldt 5 6

5 Expectation Expectation. Given a discrete random variable X, its expectation E[X] is defined by: E[X] = j Pr[X = j] Waiting for a first success. Coin is heads with probability p and tails with probability p. How many independent flips X until first heads? E[X] = j Pr[X = j] = j ( p) j p p = p j tails head j ( p) j = p p p = p 2 p 8 Expectation: two properties Guessing cards Useful property. If X is a 0/ random variable, E[X] = Pr[X = ]. Pf. E[X] = j Pr[X = j] = j Pr[X = j] = Pr[X =] not necessarily independent Linearity of expectation. Given two random variables X and Y defined over the same probability space, E[X + Y] = E[X] + E[Y]. Benefit. Decouples a complex calculation into simpler pieces. Game. Shuffle a deck of n cards; turn them over one at a time; try to guess each card. Memoryless guessing. No psychic abilities; can t even remember what s been turned over already. Guess a card from full deck uniformly at random. Claim. The expected number of correct guesses is. Pf. [ surprisingly effortless using linearity of expectation ] Let X i = if i th prediction is correct and 0 otherwise. Let X = number of correct guesses = X + + X n. E[X i ] = Pr[X i = ] = / n. E[X] = E[X ] + + E[X n ] = / n + + / n =. linearity of expectation 9 20

6 Guessing cards Coupon collector Game. Shuffle a deck of n cards; turn them over one at a time; try to guess each card. Guessing with memory. Guess a card uniformly at random from cards not yet seen. Claim. The expected number of correct guesses is Θ(log n). Pf. Let X i = if i th prediction is correct and 0 otherwise. Let X = number of correct guesses = X + + X n. E[X i ] = Pr[X i = ] = / (n ( i )). E[X] = E[X ] + + E[X n ] = / n + + / 2 + / = H(n). Coupon collector. Each box of cereal contains a coupon. There are n different types of coupons. Assuming all boxes are equally likely to contain each coupon, how many boxes before you have coupon of each type? Claim. The expected number of steps is Θ(n log n). Pf. Phase j = time between j and j + distinct coupons. Let X j = number of steps you spend in phase j. Let X = number of steps in total = X 0 + X + + X n. n E[X] = E[X j ] = n n n = n n j i= i = n H(n) linearity of expectation ln(n+) < H(n) < + ln n prob of success = (n j) / n expected waiting time = n / (n j) 2 22 Maximum 3-satisfiability exactly 3 distinct literals per clause Maximum 3-satisfiability. Given a 3-SAT formula, find a truth assignment that satisfies as many clauses as possible. C = x 2 x 3 x 4 C 2 = x 2 x 3 x 4 C 3 = x x 2 x 4 C 4 = x x 2 x 3 C 5 = x x 2 x 4 Remark. NP-hard search problem. Simple idea. Flip a coin, and set each variable true with probability ½, independently for each variable. 24

7 Maximum 3-satisfiability: analysis The probabilistic method Claim. Given a 3-SAT formula with k clauses, the expected number of Corollary. For any instance of 3-SAT, there exists a truth assignment that clauses satisfied by a random assignment is 7k / 8. satisfies at least a 7/8 fraction of all clauses. " if clause C j is satisfied Zj = # $ 0 otherwise. Pf. Consider random variable Pf. Random variable is at least its expectation some of the time. satisfied by random assignment. Let Z = number of clauses k E[Z ] = linearity of expectation E[Z j ] Probabilistic method. [Paul Erdös] Prove the existence of a non-obvious j= k property by showing that a random construction produces it with = Pr[clause C j is satisfied] = j= 7k 8 positive probability! Maximum 3-satisfiability: analysis Maximum 3-satisfiability: analysis Q. Can we turn this idea into a 7/8-approximation algorithm? Johnson s algorithm. Repeatedly generate random truth assignments until A. Yes (but a random variable can almost always be below its mean). one of them satisfies 7k / 8 clauses. Lemma. The probability that a random assignment satisfies 7k / 8 clauses Theorem. Johnson s algorithm is a 7/8-approximation algorithm. is at least / (8k). Pf. By previous lemma, each iteration succeeds with probability / (8k). Pf. Let pj be probability that exactly j clauses are satisfied; By the waiting-time bound, the expected number of trials to find the let p be probability that 7k / 8 clauses are satisfied. satisfying assignment is at most 8k. 7k 8 = E[Z ] = j pj j 0 = j pj + j < 7k /8 j pj j 7k /8 ( 7k 8 ) p j + k p j 8 j < 7k /8 j 7k /8 ( 87 k 8 ) + k p Rearranging terms yields p / (8k)

8 Maximum satisfiability Extensions. Allow one, two, or more literals per clause. Find max weighted set of satisfied clauses. Theorem. [Asano Williamson 2000] There exists a approximation algorithm for MAX-SAT. Monte Carlo vs. Las Vegas algorithms Monte Carlo. Guaranteed to run in poly-time, likely to find correct answer. Ex: Contraction algorithm for global min cut. Las Vegas. Guaranteed to find correct answer, likely to run in poly-time. Ex: Randomized quicksort, Johnson s MAX-3-SAT algorithm. Theorem. [Karloff Zwick 997, Zwick+computer 2002] There exists a 7/8- approximation algorithm for version of MAX-3-SAT in which each clause has at most 3 literals. Theorem. [Håstad 997] Unless P = NP, no ρ-approximation algorithm for MAX-3-SAT (and hence MAX-SAT) for any ρ > 7/8. Remark. Can always convert a Las Vegas algorithm into Monte Carlo, but no known method (in general) to convert the other way. stop algorithm after a certain point very unlikely to improve over simple randomized algorithm for MAX-3-SAT RP and ZPP RP. [Monte Carlo] Decision problems solvable with one-sided error in poly-time. One-sided error. If the correct answer is no, always return no. If the correct answer is yes, return yes with probability ½. ZPP. [Las Vegas] Decision problems solvable in expected poly-time. Theorem. P ZPP RP NP. Fundamental open questions. To what extent does randomization help? Does P = ZPP? Does ZPP = RP? Does RP = NP? can decrease probability of false negative to 2-00 by 00 independent repetitions running time can be unbounded, but fast on average 3

9 Dictionary data type Hashing Dictionary. Given a universe U of possible elements, maintain a subset S U so that inserting, deleting, and searching in S is efficient. Dictionary interface. create(): initialize a dictionary with S =. insert(u): add element u U to S. delete(u): delete u from S (if u is currently in S). lookup(u): is u in S? Hash function. h : U { 0,,, n }. Hashing. Create an array a of length n. When processing element u, access array element a[h(u)]. birthday paradox Collision. When h(u) = h(v) but u v. A collision is expected after Θ( n) random insertions. Separate chaining: a[i] stores linked list of elements u with h(u) = i. Challenge. Universe U can be extremely large so defining an array of size U is infeasible. a[0] a[] jocularly null seriously Applications. File systems, databases, Google, compilers, checksums P2P networks, associative arrays, cryptography, web caching, etc. a[2] suburban untravelled considerating a[n-] browsing Ad-hoc hash function Ad-hoc hash function. int hash(string s, int n) { int hash = 0; for (int i = 0; i < s.length(); i++) hash = (3 * hash) + s[i]; return hash % n; } hash function à la Java string library Deterministic hashing. If U n 2, then for any fixed hash function h, there is a subset S U of n elements that all hash to same slot. Thus, Θ(n) time per lookup in worst-case. Algorithmic complexity attacks When can t we live with ad-hoc hash function? Obvious situations: aircraft control, nuclear reactor, pace maker,. Surprising situations: denial-of-service attacks. malicious adversary learns your ad-hoc hash function (e.g., by reading Java API) and causes a big pile-up in a single slot that grinds performance to a halt Real world exploits. [Crosby Wallach 2003] Linux kernel: save files with carefully chosen names. Perl 5.8.0: insert carefully chosen strings into associative array. Bro server: send carefully chosen packets to DOS the server, using less bandwidth than a dial-up modem. Q. But isn t ad-hoc hash function good enough in practice? 35 36

10 Hashing performance Ideal hash function. Maps m elements uniformly at random to n hash slots. Running time depends on length of chains. Average length of chain = α = m / n. Choose n m expect O() per insert, lookup, or delete. Universal hashing (Carter Wegman 980s) A universal family of hash functions is a set of hash functions H mapping a universe U to the set { 0,,, n } such that For any pair of elements u v : Pr h H h(u) = h(v) Can select random h efficiently. Can compute h(u) efficiently. [ ] /n chosen uniformly at random Challenge. Explicit hash function h that achieves O() per operation. Approach. Use randomization for the choice of h. adversary knows the randomized algorithm you re using, but doesn t know random choice that the algorithm makes Ex. U = { a, b, c, d, e, f }, n = 2. a b c d e f h (x) h 2 (x) H = {h, h 2 } Pr h H [h(a) = h(b)] = /2 Pr h H [h(a) = h(c)] = Pr h H [h(a) = h(d)] = 0... not universal h (x) h 2 (x) h 3 (x) h 4 (x) a b c d e f H = {h, h 2, h 3, h 4 } Pr h H [h(a) = h(b)] = /2 Pr h H [h(a) = h(c)] = /2 Pr h H [h(a) = h(d)] = /2 Pr h H [h(a) = h(e)] = /2 Pr h H [h(a) = h(f)] = 0 universal Universal hashing: analysis Designing a universal family of hash functions Proposition. Let H be a universal family of hash functions mapping a universe U to the set { 0,,, n }; let h H be chosen uniformly at random from H; let S U be a subset of size at most n; and let u S. Then, the expected number of items in S that collide with u is at most. Modulus. We will use a prime number p for the size of the hash table. Integer encoding. Identify each element u U with a base-p integer of r digits: x = (x, x 2,, x r ). Pf. For any s S, define random variable X s = if h(s) = h(u), and 0 otherwise. Let X be a random variable counting the total number of collisions with u. Hash function. Let A = set of all r-digit, base-p integers. For each a = (a, a 2,, a r ) where 0 a i < p, define E h H [X] = E[ s S X s ] = s S E[X s ] = s S Pr[X s =] s S n = S n h a (x) = # r & % a i x i ( mod p maps universe U to set { 0,,, p } $ ' i= linearity of expectation Xs is a 0 random variable universal Hash function family. H = { h a : a A }. Q. OK, but how do we design a universal class of hash functions? 39 40

11 Designing a universal family of hash functions Number theory fact Theorem. H = { h a : a A } is a universal family of hash functions. Pf. Let x = (x, x 2,, x r ) and y = (y, y 2,, y r ) be two distinct elements of U. We need to show that Pr[h a (x) = h a (y)] / p. Since x y, there exists an integer j such that x j y j. We have h a (x) = h a (y) iff a j ( y j x j )!# "# $ z = a i (x i y i ) mod p i j!# "## $ Can assume a was chosen uniformly at random by first selecting all coordinates a i where i j, then selecting a j at random. Thus, we can assume a i is fixed for all coordinates i j. Since p is prime, a j z m mod p has at most one solution among p possibilities. see lemma on next slide Thus Pr[h a (x) = h a (y)] / p. m Fact. Let p be prime, and let z 0 mod p. Then α z m mod p has at most one solution 0 α < p. Pf. Suppose 0 α < p and 0 α 2 < p are two different solutions. Then (α α 2) z 0 mod p; hence (α α 2) z is divisible by p. Since z 0 mod p, we know that z is not divisible by p. It follows that (α α 2) is divisible by p. This implies α = α 2. Bonus fact. Can replace at most one with exactly one in above fact. Pf idea. Euclid s algorithm. here s where we use that p is prime 4 42 Universal hashing: summary Goal. Given a universe U, maintain a subset S U so that insert, delete, and lookup are efficient. Universal hash function family. H = { h a : a A }. h a (x) = # r & % a i x i ( mod p $ ' i= Choose p prime so that m p 2m, where m = S. Fact: there exists a prime between m and 2m. Consequence. Space used = Θ(m). Expected number of collisions per operation is O() time per insert, delete, or lookup. can find such a prime using another randomized algorithm (!) 43

12 Chernoff Bounds (above mean) Chernoff Bounds (above mean) Theorem. Suppose X,, X n are independent 0- random variables. Let X = X + + X n. Then for any µ E[X] and for any δ > 0, we have Pf. [ continued ] Let p i = Pr [X i = ]. Then, sum of independent 0- random variables is tightly centered on the mean Combining everything: for any α 0, +α e α Pf. We apply a number of simple transformations. For any t > 0, Pr[X > (+ δ)µ] = Pr e t X > e t(+δ)µ [ ] e t(+δ)µ E[e tx ] Pr[X > (+ δ)µ] e t(+δ)µ E[e t X i i ] e t(+δ)µ e p i (e t ) i e t(+δ)µ e µ(et ) previous slide inequality above i p i = E[X] µ f(x) = e tx is monotone in x Markov s inequality: Pr[X > a] E[X] / a Now E[e tx ] = E[e t X i i ] = E[e t X i ] i Finally, choose t = ln( + δ). definition of X independence Chernoff Bounds (below mean) Theorem. Suppose X,, X n are independent 0- random variables. Let X = X + + X n. Then for any µ E [X ] and for any 0 < δ <, we have Pf idea. Similar. Remark. Not quite symmetric since only makes sense to consider δ <. 47

13 Load balancing Load balancing Load balancing. System in which m jobs arrive in a stream and need to be processed immediately on m identical processors. Find an assignment that balances the workload across processors. Centralized controller. Assign jobs in round-robin manner. Each processor receives at most m / n jobs. Decentralized controller. Assign jobs to processors uniformly at random. How likely is it that some processor is assigned too many jobs? Analysis. Let X i = number of jobs assigned to processor i. Let Y ij = if job j assigned to processor i, and 0 otherwise. We have E[Y ij ] = /n. Thus, X i = j Y i j, and μ = E[X i ] =. Applying Chernoff bounds with δ = c yields Let γ(n) be number x such that x x = n, and choose c = e γ(n). Union bound with probability /n no processor receives more than e γ(n) = Θ(log n / log log n) jobs. Bonus fact: with high probability, some processor receives Θ(logn / log log n) jobs Load balancing: many jobs Theorem. Suppose the number of jobs m = 6 n ln n. Then on average, each of the n processors handles μ = 6 ln n jobs. With high probability, every processor will have between half and twice the average load. Pf. Let X i, Y ij be as before. Applying Chernoff bounds with δ = yields Pr[X i > 2µ] < e 4 6n ln n < e ln n = n 2 Pr X i < 2 µ < e 2 ( 2 )2 6n ln n = n 2 Union bound every processor has load between half and twice the average with probability 2/n. 5

13. RANDOMIZED ALGORITHMS

13. RANDOMIZED ALGORITHMS 13. RANDOMIZED ALGORITHMS content resolution global min cut linearity of expectation max 3-satisfiability universal hashing Chernoff bounds load balancing Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison

More information

Chapter 13. Randomized Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 13. Randomized Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 13 Randomized Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 Randomization Algorithmic design patterns. Greedy. Divide-and-conquer. Dynamic programming.

More information

CS 580: Algorithm Design and Analysis

CS 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 information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Reminder: Homework 6 has been released. Chapter 13 Randomized Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 Global Minimum Cut Contraction Algorithm 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

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 CS 580: Algorithm Design and Analysis.8 Knapsack Problem Jeremiah Blocki Purdue University Spring 08 Reminder: Homework 6 has been released. Weighted Vertex Cover Polynomial Time Approximation Scheme Theorem.

More information

Outline. CS38 Introduction to Algorithms. Max-3-SAT approximation algorithm 6/3/2014. randomness in algorithms. Lecture 19 June 3, 2014

Outline. CS38 Introduction to Algorithms. Max-3-SAT approximation algorithm 6/3/2014. randomness in algorithms. Lecture 19 June 3, 2014 Outline CS38 Introduction to Algorithms Lecture 19 June 3, 2014 randomness in algorithms max-3-sat approximation algorithm universal hashing load balancing Course summary and review June 3, 2014 CS38 Lecture

More information

Τίτλος Μαθήματος: Θεωρία Πολυπλοκότητας. Ενότητα: Τυχαιοποιημένοι αλγόριθμοι. Διδάσκων: Λέκτορας Xάρης Παπαδόπουλος. Τμήμα: Μαθηματικών

Τίτλος Μαθήματος: Θεωρία Πολυπλοκότητας. Ενότητα: Τυχαιοποιημένοι αλγόριθμοι. Διδάσκων: Λέκτορας Xάρης Παπαδόπουλος. Τμήμα: Μαθηματικών Τίτλος Μαθήματος: Θεωρία Πολυπλοκότητας Ενότητα: Τυχαιοποιημένοι αλγόριθμοι Διδάσκων: Λέκτορας Xάρης Παπαδόπουλος Τμήμα: Μαθηματικών Chapter 13: Randomized Algorithms Randomization Algorithmic design

More information

Randomized Algorithms. Zhou Jun

Randomized Algorithms. Zhou Jun Randomized Algorithms Zhou Jun 1 Content 13.1 Contention Resolution 13.2 Global Minimum Cut 13.3 *Random Variables and Expectation 13.4 Randomized Approximation Algorithm for MAX 3- SAT 13.6 Hashing 13.7

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Lectures 2-3 Algorithms with Numbers Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments

More information

Theorem 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( ) 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 information

1 Maintaining a Dictionary

1 Maintaining a Dictionary 15-451/651: Design & Analysis of Algorithms February 1, 2016 Lecture #7: Hashing last changed: January 29, 2016 Hashing is a great practical tool, with an interesting and subtle theory too. In addition

More information

Hash tables. Hash tables

Hash tables. Hash tables Dictionary Definition A dictionary is a data-structure that stores a set of elements where each element has a unique key, and supports the following operations: Search(S, k) Return the element whose key

More information

Hash tables. Hash tables

Hash tables. Hash tables Dictionary Definition A dictionary is a data-structure that stores a set of elements where each element has a unique key, and supports the following operations: Search(S, k) Return the element whose key

More information

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria 12. LOCAL SEARCH gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley h ttp://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM 8. INTRACTABILITY I poly-time reductions packing and covering problems constraint satisfaction problems sequencing problems partitioning problems graph coloring numerical problems Lecture slides by Kevin

More information

-bit integers are all in ThC. Th The following problems are complete for PSPACE NPSPACE ATIME QSAT, GEOGRAPHY, SUCCINCT REACH.

-bit integers are all in ThC. Th The following problems are complete for PSPACE NPSPACE ATIME QSAT, GEOGRAPHY, SUCCINCT REACH. CMPSCI 601: Recall From Last Time Lecture 26 Theorem: All CFL s are in sac. Facts: ITADD, MULT, ITMULT and DIVISION on -bit integers are all in ThC. Th The following problems are complete for PSPACE NPSPACE

More information

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds Randomized Algorithms Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds Sotiris Nikoletseas Associate Professor CEID - ETY Course 2013-2014 Sotiris Nikoletseas, Associate Professor Randomized

More information

Randomized Algorithms

Randomized 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 information

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 Approximation Algorithms Q. Suppose I need to solve an NP-hard problem. What should

More information

Hash tables. Hash tables

Hash tables. Hash tables Basic Probability Theory Two events A, B are independent if Conditional probability: Pr[A B] = Pr[A] Pr[B] Pr[A B] = Pr[A B] Pr[B] The expectation of a (discrete) random variable X is E[X ] = k k Pr[X

More information

compare to comparison and pointer based sorting, binary trees

compare to comparison and pointer based sorting, binary trees Admin Hashing Dictionaries Model Operations. makeset, insert, delete, find keys are integers in M = {1,..., m} (so assume machine word size, or unit time, is log m) can store in array of size M using power:

More information

CS 125 Section #12 (More) Probability and Randomized Algorithms 11/24/14. For random numbers X which only take on nonnegative integer values, E(X) =

CS 125 Section #12 (More) Probability and Randomized Algorithms 11/24/14. For random numbers X which only take on nonnegative integer values, E(X) = CS 125 Section #12 (More) Probability and Randomized Algorithms 11/24/14 1 Probability First, recall a couple useful facts from last time about probability: Linearity of expectation: E(aX + by ) = ae(x)

More information

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is: CS 24 Section #8 Hashing, Skip Lists 3/20/7 Probability Review Expectation (weighted average): the expectation of a random quantity X is: x= x P (X = x) For each value x that X can take on, we look at

More information

Lecture 4: Two-point Sampling, Coupon Collector s problem

Lecture 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 information

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria Coping With NP-hardness Q. Suppose I need to solve an NP-hard problem. What should I do? A. Theory says you re unlikely to find poly-time algorithm. Must sacrifice one of three desired features. Solve

More information

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 P and NP P: The family of problems that can be solved quickly in polynomial time.

More information

CS/COE

CS/COE CS/COE 1501 www.cs.pitt.edu/~nlf4/cs1501/ P vs NP But first, something completely different... Some computational problems are unsolvable No algorithm can be written that will always produce the correct

More information

CS261: A Second Course in Algorithms Lecture #18: Five Essential Tools for the Analysis of Randomized Algorithms

CS261: A Second Course in Algorithms Lecture #18: Five Essential Tools for the Analysis of Randomized Algorithms CS261: A Second Course in Algorithms Lecture #18: Five Essential Tools for the Analysis of Randomized Algorithms Tim Roughgarden March 3, 2016 1 Preamble In CS109 and CS161, you learned some tricks of

More information

Random Variable. Pr(X = a) = Pr(s)

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 information

N/4 + N/2 + N = 2N 2.

N/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 information

A An Overview of Complexity Theory for the Algorithm Designer

A An Overview of Complexity Theory for the Algorithm Designer A An Overview of Complexity Theory for the Algorithm Designer A.1 Certificates and the class NP A decision problem is one whose answer is either yes or no. Two examples are: SAT: Given a Boolean formula

More information

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 32

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 32 CS 473: Algorithms Ruta Mehta University of Illinois, Urbana-Champaign Spring 2018 Ruta (UIUC) CS473 1 Spring 2018 1 / 32 CS 473: Algorithms, Spring 2018 Universal Hashing Lecture 10 Feb 15, 2018 Most

More information

P, NP, NP-Complete, and NPhard

P, NP, NP-Complete, and NPhard P, NP, NP-Complete, and NPhard Problems Zhenjiang Li 21/09/2011 Outline Algorithm time complicity P and NP problems NP-Complete and NP-Hard problems Algorithm time complicity Outline What is this course

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 14 October 16, 2013 CPSC 467, Lecture 14 1/45 Message Digest / Cryptographic Hash Functions Hash Function Constructions Extending

More information

CSE 190, Great ideas in algorithms: Pairwise independent hash functions

CSE 190, Great ideas in algorithms: Pairwise independent hash functions CSE 190, Great ideas in algorithms: Pairwise independent hash functions 1 Hash functions The goal of hash functions is to map elements from a large domain to a small one. Typically, to obtain the required

More information

CSE 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 ) 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 information

Lecture Notes CS:5360 Randomized Algorithms Lecture 20 and 21: Nov 6th and 8th, 2018 Scribe: Qianhang Sun

Lecture Notes CS:5360 Randomized Algorithms Lecture 20 and 21: Nov 6th and 8th, 2018 Scribe: Qianhang Sun 1 Probabilistic Method Lecture Notes CS:5360 Randomized Algorithms Lecture 20 and 21: Nov 6th and 8th, 2018 Scribe: Qianhang Sun Turning the MaxCut proof into an algorithm. { Las Vegas Algorithm Algorithm

More information

9. PSPACE 9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

9. PSPACE 9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete Geography game Geography. Alice names capital city c of country she is in. Bob names a capital city c' that starts with the letter on which c ends. Alice and Bob repeat this game until one player is unable

More information

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete 9. PSPACE PSPACE complexity class quantified satisfiability planning problem PSPACE-complete Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018 CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Chapter 9 PSPACE: A Class of Problems Beyond NP Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights

More information

Lecture: Analysis of Algorithms (CS )

Lecture: Analysis of Algorithms (CS ) Lecture: Analysis of Algorithms (CS483-001) Amarda Shehu Spring 2017 1 Outline of Today s Class 2 Choosing Hash Functions Universal Universality Theorem Constructing a Set of Universal Hash Functions Perfect

More information

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam Limits to Approximability: When Algorithms Won't Help You Note: Contents of today s lecture won t be on the exam Outline Limits to Approximability: basic results Detour: Provers, verifiers, and NP Graph

More information

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Randomization Randomized Algorithm: An algorithm that uses (or can use) random coin flips in order to make decisions We will see: randomization

More information

6.1 Occupancy Problem

6.1 Occupancy Problem 15-859(M): Randomized Algorithms Lecturer: Anupam Gupta Topic: Occupancy Problems and Hashing Date: Sep 9 Scribe: Runting Shi 6.1 Occupancy Problem Bins and Balls Throw n balls into n bins at random. 1.

More information

2. ALGORITHM ANALYSIS

2. ALGORITHM ANALYSIS 2. ALGORITHM ANALYSIS computational tractability asymptotic order of growth survey of common running times Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

Expectation of geometric distribution

Expectation 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 information

Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn Randomization Randomized Algorithm: An algorithm that uses (or can use) random coin flips in order to make decisions We will see: randomization

More information

NP Completeness and Approximation Algorithms

NP Completeness and Approximation Algorithms Chapter 10 NP Completeness and Approximation Algorithms Let C() be a class of problems defined by some property. We are interested in characterizing the hardest problems in the class, so that if we can

More information

Lecture 2 Sep 5, 2017

Lecture 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 information

Essential facts about NP-completeness:

Essential facts about NP-completeness: CMPSCI611: NP Completeness Lecture 17 Essential facts about NP-completeness: Any NP-complete problem can be solved by a simple, but exponentially slow algorithm. We don t have polynomial-time solutions

More information

Adleman Theorem and Sipser Gács Lautemann Theorem. CS422 Computation Theory CS422 Complexity Theory

Adleman Theorem and Sipser Gács Lautemann Theorem. CS422 Computation Theory CS422 Complexity Theory Adleman Theorem and Sipser Gács Lautemann Theorem CS422 Computation Theory CS422 Complexity Theory Complexity classes, N, co N, SACE, EXTIME, H, R, RE, ALL, Complexity theorists: "Which is contained in

More information

CSE 502 Class 11 Part 2

CSE 502 Class 11 Part 2 CSE 502 Class 11 Part 2 Jeremy Buhler Steve Cole February 17 2015 Today: analysis of hashing 1 Constraints of Double Hashing How does using OA w/double hashing constrain our hash function design? Need

More information

CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash

CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash Equilibrium Price of Stability Coping With NP-Hardness

More information

Randomized Complexity Classes; RP

Randomized Complexity Classes; RP Randomized Complexity Classes; RP Let N be a polynomial-time precise NTM that runs in time p(n) and has 2 nondeterministic choices at each step. N is a polynomial Monte Carlo Turing machine for a language

More information

Tail Inequalities Randomized Algorithms. Sariel Har-Peled. December 20, 2002

Tail Inequalities Randomized Algorithms. Sariel Har-Peled. December 20, 2002 Tail Inequalities 497 - Randomized Algorithms Sariel Har-Peled December 0, 00 Wir mssen wissen, wir werden wissen (We must know, we shall know) David Hilbert 1 Tail Inequalities 1.1 The Chernoff Bound

More information

COP 4531 Complexity & Analysis of Data Structures & Algorithms

COP 4531 Complexity & Analysis of Data Structures & Algorithms COP 4531 Complexity & Analysis of Data Structures & Algorithms Lecture 18 Reductions and NP-completeness Thanks to Kevin Wayne and the text authors who contributed to these slides Classify Problems According

More information

Randomized Computation

Randomized Computation Randomized Computation Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach. Ahto Buldas Ahto.Buldas@ut.ee We do not assume anything about the distribution of the instances of the problem

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Computational Complexity CLRS 34.1-34.4 University of Manitoba COMP 3170 - Analysis of Algorithms & Data Structures 1 / 50 Polynomial

More information

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2013

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2013 University of New Mexico Department of Computer Science Final Examination CS 561 Data Structures and Algorithms Fall, 2013 Name: Email: This exam lasts 2 hours. It is closed book and closed notes wing

More information

Analysis of Algorithms I: Perfect Hashing

Analysis of Algorithms I: Perfect Hashing Analysis of Algorithms I: Perfect Hashing Xi Chen Columbia University Goal: Let U = {0, 1,..., p 1} be a huge universe set. Given a static subset V U of n keys (here static means we will never change the

More information

20.1 2SAT. CS125 Lecture 20 Fall 2016

20.1 2SAT. CS125 Lecture 20 Fall 2016 CS125 Lecture 20 Fall 2016 20.1 2SAT We show yet another possible way to solve the 2SAT problem. Recall that the input to 2SAT is a logical expression that is the conunction (AND) of a set of clauses,

More information

11.1 Set Cover ILP formulation of set cover Deterministic rounding

11.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 information

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 8.5 Sequencing Problems Basic genres.! Packing problems: SET-PACKING,

More information

CSE525: Randomized Algorithms and Probabilistic Analysis April 2, Lecture 1

CSE525: Randomized Algorithms and Probabilistic Analysis April 2, Lecture 1 CSE525: Randomized Algorithms and Probabilistic Analysis April 2, 2013 Lecture 1 Lecturer: Anna Karlin Scribe: Sonya Alexandrova and Eric Lei 1 Introduction The main theme of this class is randomized algorithms.

More information

Lecture 5: Two-point Sampling

Lecture 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 information

Expectation of geometric distribution. Variance and Standard Deviation. Variance: Examples

Expectation 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 information

Chapter 9. PSPACE: A Class of Problems Beyond NP. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 9. PSPACE: A Class of Problems Beyond NP. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 9 PSPACE: A Class of Problems Beyond NP Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 Geography Game Geography. Alice names capital city c of country she

More information

6.045: Automata, Computability, and Complexity (GITCS) Class 17 Nancy Lynch

6.045: Automata, Computability, and Complexity (GITCS) Class 17 Nancy Lynch 6.045: Automata, Computability, and Complexity (GITCS) Class 17 Nancy Lynch Today Probabilistic Turing Machines and Probabilistic Time Complexity Classes Now add a new capability to standard TMs: random

More information

Analysis of Algorithms CMPSC 565

Analysis 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 information

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm Outline 1 NP-Completeness Theory 2 Limitation of Computation 3 Examples 4 Decision Problems 5 Verification Algorithm 6 Non-Deterministic Algorithm 7 NP-Complete Problems c Hu Ding (Michigan State University)

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 25 Last time Class NP Today Polynomial-time reductions Adam Smith; Sofya Raskhodnikova 4/18/2016 L25.1 The classes P and NP P is the class of languages decidable

More information

Limitations of Algorithm Power

Limitations of Algorithm Power Limitations of Algorithm Power Objectives We now move into the third and final major theme for this course. 1. Tools for analyzing algorithms. 2. Design strategies for designing algorithms. 3. Identifying

More information

CS145: Probability & Computing Lecture 24: Algorithms

CS145: 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 information

Lecture 18: P & NP. Revised, May 1, CLRS, pp

Lecture 18: P & NP. Revised, May 1, CLRS, pp Lecture 18: P & NP Revised, May 1, 2003 CLRS, pp.966-982 The course so far: techniques for designing efficient algorithms, e.g., divide-and-conquer, dynamic-programming, greedy-algorithms. What happens

More information

Lecture 6,7 (Sept 27 and 29, 2011 ): Bin Packing, MAX-SAT

Lecture 6,7 (Sept 27 and 29, 2011 ): Bin Packing, MAX-SAT ,7 CMPUT 675: Approximation Algorithms Fall 2011 Lecture 6,7 (Sept 27 and 29, 2011 ): Bin Pacing, MAX-SAT Lecturer: Mohammad R. Salavatipour Scribe: Weitian Tong 6.1 Bin Pacing Problem Recall the bin pacing

More information

CPSC 536N: Randomized Algorithms Term 2. Lecture 2

CPSC 536N: Randomized Algorithms Term 2. Lecture 2 CPSC 536N: Randomized Algorithms 2014-15 Term 2 Prof. Nick Harvey Lecture 2 University of British Columbia In this lecture we continue our introduction to randomized algorithms by discussing the Max Cut

More information

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch] NP-Completeness Andreas Klappenecker [based on slides by Prof. Welch] 1 Prelude: Informal Discussion (Incidentally, we will never get very formal in this course) 2 Polynomial Time Algorithms Most of the

More information

Introduction to Randomized Algorithms: Quick Sort and Quick Selection

Introduction 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 information

Algorithms Design & Analysis. Approximation Algorithm

Algorithms Design & Analysis. Approximation Algorithm Algorithms Design & Analysis Approximation Algorithm Recap External memory model Merge sort Distribution sort 2 Today s Topics Hard problem Approximation algorithms Metric traveling salesman problem A

More information

NP and Computational Intractability

NP and Computational Intractability NP and Computational Intractability 1 Review Basic reduction strategies. Simple equivalence: INDEPENDENT-SET P VERTEX-COVER. Special case to general case: VERTEX-COVER P SET-COVER. Encoding with gadgets:

More information

Computational Intractability 2010/4/15. Lecture 2

Computational Intractability 2010/4/15. Lecture 2 Computational Intractability 2010/4/15 Professor: David Avis Lecture 2 Scribe:Naoki Hatta 1 P and NP 1.1 Definition of P and NP Decision problem it requires yes/no answer. Example: X is a set of strings.

More information

Essentials on the Analysis of Randomized Algorithms

Essentials on the Analysis of Randomized Algorithms Essentials on the Analysis of Randomized Algorithms Dimitris Diochnos Feb 0, 2009 Abstract These notes were written with Monte Carlo algorithms primarily in mind. Topics covered are basic (discrete) random

More information

CS Communication Complexity: Applications and New Directions

CS Communication Complexity: Applications and New Directions CS 2429 - Communication Complexity: Applications and New Directions Lecturer: Toniann Pitassi 1 Introduction In this course we will define the basic two-party model of communication, as introduced in the

More information

6. DYNAMIC PROGRAMMING I

6. DYNAMIC PROGRAMMING I 6. DYNAMIC PROGRAMMING I weighted interval scheduling segmented least squares knapsack problem RNA secondary structure Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013

More information

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem. 1 More on NP In this set of lecture notes, we examine the class NP in more detail. We give a characterization of NP which justifies the guess and verify paradigm, and study the complexity of solving search

More information

14.1 Finding frequent elements in stream

14.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 information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 16 October 30, 2017 CPSC 467, Lecture 16 1/52 Properties of Hash Functions Hash functions do not always look random Relations among

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 26 Computational Intractability Polynomial Time Reductions Sofya Raskhodnikova S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.1 What algorithms are

More information

Algorithms for Data Science

Algorithms for Data Science Algorithms for Data Science CSOR W4246 Eleni Drinea Computer Science Department Columbia University Tuesday, December 1, 2015 Outline 1 Recap Balls and bins 2 On randomized algorithms 3 Saving space: hashing-based

More information

Approximation Algorithms

Approximation Algorithms Approximation Algorithms What do you do when a problem is NP-complete? or, when the polynomial time solution is impractically slow? assume input is random, do expected performance. Eg, Hamiltonian path

More information

Chapter 8. NP and Computational Intractability

Chapter 8. NP and Computational Intractability Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Acknowledgement: This lecture slide is revised and authorized from Prof.

More information

NP-Complete Problems. More reductions

NP-Complete Problems. More reductions NP-Complete Problems More reductions Definitions P: problems that can be solved in polynomial time (typically in n, size of input) on a deterministic Turing machine Any normal computer simulates a DTM

More information

SOLUTION: SOLUTION: SOLUTION:

SOLUTION: SOLUTION: SOLUTION: Convert R and S into nondeterministic finite automata N1 and N2. Given a string s, if we know the states N1 and N2 may reach when s[1...i] has been read, we are able to derive the states N1 and N2 may

More information

Lecture 24 Nov. 20, 2014

Lecture 24 Nov. 20, 2014 CS 224: Advanced Algorithms Fall 2014 Prof. Jelani Nelson Lecture 24 Nov. 20, 2014 Scribe: Xiaoyu He Overview Today we will move to a new topic: another way to deal with NP-hard problems. We have already

More information

6.842 Randomness and Computation Lecture 5

6.842 Randomness and Computation Lecture 5 6.842 Randomness and Computation 2012-02-22 Lecture 5 Lecturer: Ronitt Rubinfeld Scribe: Michael Forbes 1 Overview Today we will define the notion of a pairwise independent hash function, and discuss its

More information

Homework 4 Solutions

Homework 4 Solutions CS 174: Combinatorics and Discrete Probability Fall 01 Homework 4 Solutions Problem 1. (Exercise 3.4 from MU 5 points) Recall the randomized algorithm discussed in class for finding the median of a set

More information

Lecture 1 : Probabilistic Method

Lecture 1 : Probabilistic Method IITM-CS6845: Theory Jan 04, 01 Lecturer: N.S.Narayanaswamy Lecture 1 : Probabilistic Method Scribe: R.Krithika The probabilistic method is a technique to deal with combinatorial problems by introducing

More information

Lecture 5: Hashing. David Woodruff Carnegie Mellon University

Lecture 5: Hashing. David Woodruff Carnegie Mellon University Lecture 5: Hashing David Woodruff Carnegie Mellon University Hashing Universal hashing Perfect hashing Maintaining a Dictionary Let U be a universe of keys U could be all strings of ASCII characters of

More information

Chernoff Bounds. Theme: try to show that it is unlikely a random variable X is far away from its expectation.

Chernoff Bounds. Theme: try to show that it is unlikely a random variable X is far away from its expectation. Chernoff Bounds Theme: try to show that it is unlikely a random variable X is far away from its expectation. The more you know about X, the better the bound you obtain. Markov s inequality: use E[X ] Chebyshev

More information