Randomized Algorithms

Slides:



Advertisements
Similar presentations
Lecture 3: Randomized Algorithm and Divide and Conquer II: Shang-Hua Teng.
Advertisements

Text Chapters 1, 2. Sorting ä Sorting Problem: ä Input: A sequence of n numbers ä Output: A permutation (reordering) of the input sequence such that:
Basic Data Mining Techniques Chapter Decision Trees.
How should a computer shuffle?. Intro - 2 Comp 122, Goal  Input: Given n items to shuffle (cards, …)  Output: Return some list of exactly those n items;
BY Lecturer: Aisha Dawood. The hiring problem:  You are using an employment agency to hire a new office assistant.  The agency sends you one candidate.
Probabilistic Analysis and Randomized Algorithm. Average-Case Analysis  In practice, many algorithms perform better than their worse case  The average.
PROBABILITY AND COMPUTING RANDOMIZED ALGORITHMS AND PROBABILISTIC ANALYSIS CHAPTER 1 IWAMA and ITO Lab. M1 Sakaidani Hikaru 1.
Algorithm Design Techniques, Greedy Method – Knapsack Problem, Job Sequencing, Divide and Conquer Method – Quick Sort, Finding Maximum and Minimum, Dynamic.
Advanced Sorting 7 2  9 4   2   4   7
Sort Algorithm.
Divide and Conquer Sorting
Chapter 11 Sorting Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and Mount.
Sorting and Searching Algorithms
Sorting.
Analysis of Algorithms CS 477/677
Sorting Chapter 14.
The Stable Marriage Problem
Game Theory Just last week:
Quick Sort Divide: Partition the array into two sub-arrays
Order Statistics Comp 122, Spring 2004.
Discrete Structures for Computer Science
Lecture on Design and Analysis of Computer Algorithm
Sequences, Series, and Probability
Merge Sort 7/29/ :21 PM The Greedy Method The Greedy Method.
Minimum Spanning Tree 8/7/2018 4:26 AM
Card Shuffling How many perfect shuffles will return a full deck
Quick-Sort 9/13/2018 1:15 AM Quick-Sort     2
Chapter 7 Sorting Spring 14
Radish-Sort 11/11/ :01 AM Quick-Sort     2 9  9
The Random Class and its Methods
Algorithm Design and Analysis (ADA)
Quick-Sort 11/14/2018 2:17 PM Chapter 4: Sorting    7 9
Bucket-Sort and Radix-Sort
Quick-Sort 11/19/ :46 AM Chapter 4: Sorting    7 9
Quick Sort (11.2) CSE 2011 Winter November 2018.
Unit-2 Divide and Conquer
Merge Sort 11/28/2018 2:18 AM The Greedy Method The Greedy Method.
Merge Sort 11/28/2018 8:16 AM The Greedy Method The Greedy Method.
COUNTING AND PROBABILITY
Kruskal’s Algorithm for finding a minimum spanning tree
COSC 320 Advanced Data Structures and Algorithm Analysis
Quick sort and Radix sort
8/04/2009 Many thanks to David Sun for some of the included slides!
Divide-And-Conquer-And-Combine
Merge Sort 1/17/2019 3:11 AM The Greedy Method The Greedy Method.
Chapter 5: Probabilistic Analysis and Randomized Algorithms
Data Structures Sorting Haim Kaplan & Uri Zwick December 2014.
3. Brute Force Selection sort Brute-Force string matching
Linear-Time Sorting Algorithms
Quick-Sort 2/23/2019 1:48 AM Chapter 4: Sorting    7 9
EE 312 Software Design and Implementation I
Quicksort.
Introduction to Data Structure
Pseudorandom number, Universal Hashing, Chaining and Linear-Probing
Analysis of Algorithms
3. Brute Force Selection sort Brute-Force string matching
Chapter 9: More About Data, Arrays, and Files
Bellwork Practice Packet 10.3 B side #3.
Order Statistics Comp 122, Spring 2004.
Merge Sort 5/2/2019 7:53 PM The Greedy Method The Greedy Method.
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Chapter 5: Probabilistic Analysis and Randomized Algorithms
Randomized Algorithms
CS203 Lecture 15.
Linear Time Sorting.
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
Quicksort.
Algorithm : Design & Analysis [5]
3. Brute Force Selection sort Brute-Force string matching
Presentation transcript:

Randomized Algorithms Minimum Spanning Tree 8/4/2019 10:58 PM Random Permutations Randomized Algorithms

Generating Random Permutations The input to the random permutation problem is a list, X = (x1, x2, . . . , xn), of n elements, which could stand for playing cards or any other objects we want to randomly permute. The output is a reordering of the elements of X, done in a way so that all permutations of X are equally likely. We can use a function, random(k), which returns an integer in the range [0, k − 1] chosen uniformly and independently at random. Randomized Algorithms

Applications: Simple Algorithms and Card Games A randomized algorithm is an algorithm whose behavior depends, in part, on the outcomes of random choices or the values of random bits. The main advantage of using randomization in algorithm design is that the results are often simple and efficient. In addition, there are some problems that need randomization for them to work effectively. For instance, consider the problem common in computer games involving playing cards—that of randomly shuffling a deck of cards so that all possible orderings are equally likely. Randomized Algorithms

Algorithm 1: Random Sort This algorithm simply chooses a random number for each element in X and sorts the elements using these values as keys. Randomized Algorithms

Analysis of Random-Sort To see that every permutation is equally likely to be output by the random-sort method, note that each element, xi, in X has an equal probability, 1/n, of having its random ri value be the smallest. Thus, each element in X has equal probability of 1/n of being the first element in the permutation. Applying this reasoning recursively, implies that the permutation that is output has the following probability of being chosen: That is, each permutation is equally likely to be output. There is a small probability that this algorithm will fail, however, if the random values are not unique. Randomized Algorithms

Fisher-Yates Shuffling There is a different algorithm, known as the Fisher-Yates algorithm, which always succeeds. Randomized Algorithms

Analysis of Fisher-Yates This algorithm considers the items in the array one at time from the end and swaps each element with an element in the array from that point to the beginning. Notice that each element has an equal probability, of 1/n, of being chosen as the last element in the array X (including the element that starts out in that position). Applying this analysis recursively, we see that the output permutation has probability That is, each permutation is equally likely. Randomized Algorithms