SlideShare a Scribd company logo
1 of 30
An Introduction




Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Flip a coin




An algorithm which flip coins is called a randomized algorithm.


            Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Making decisions could be complicated.
                  A randomized algorithm is simpler.

Consider the minimum cut problem

Randomized algorithm?
                                         Pick a random edge and contract.
                                         And Continue until two vertices are left




                        Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Making good decisions could be expensive.

                  A randomized algorithm is faster.

Consider a sorting procedure.
Picking an element in the middle makes the procedure very efficient,
but it is expensive (i.e. linear time) to find such an element.


                     5 9 13 11 8         6 7 10

                5 6 7                8             9 13 11 10



                 Picking a random element will do.

                        Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Avoid worst-case behavior: randomness can
  (probabilistically) guarantee average case behavior
 Efficient approximate solutions to intractable
  problems
 In many practical problems,we need to deal with
  HUGE input,and don’t even have time to read it
  once.But can we still do something useful?




                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Deterministic
Input                                                    Output
        Computer

           Random Bits


               www.lavarnd.org
               (doesn’t use lava lamps
               anymore)




          Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Randomized algorithms make random rather than
  deterministic decisions.
 The main advantage is that no input can reliably
  produce worst-case results because the algorithm runs
  differently each time.
 These algorithms are commonly used in situations
  where no exact and fast algorithm is known.
 Behavior can vary even on a fixed input.




                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Minimum spanning trees

  A linear time randomized algorithm,
  but no known linear time deterministic algorithm.
 Primality testing

  A randomized polynomial time algorithm,
  but it takes thirty years to find a deterministic one.
 Volume estimation of a convex body

  A randomized polynomial time approximation algorithm,
  but no known deterministic polynomial time approximation algorithm.


                          Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Monte Carlo                                      Las Vegas




              Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Always gives the true answer.
 Running time is random.
 Running time is variable whose expectation is
  bounded(say by a polynomail).
 E.g. Randomized QuickSort Algorithm




                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 It may produce incorrect answer!
 We are able to bound its probability.
 By running it many times on independent random
  variables, we can make the failure probability
  arbitrarily small at the expense of running time.
 E.g. Randomized Mincut Algorithm




                    Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Suppose we want to find a number among n given
 numbers which is larger than or equal to the median.




                  Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Suppose A1 < … < An.
We want Ai, such that i ≥ n/2.

It’s obvious that the best deterministic algorithm needs
   O(n) time to produce the answer.
n may be very large!
Suppose n is 100,000,000,000 !




                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Choose 100 of the numbers with equal probability.
 find the maximum among these numbers.
 Return the maximum.




                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 The running time of the given algorithm is O(1).
 The probability of Failure is 1/(2100).
 Consider that the algorithm may return a wrong
  answer but the probability is very smaller than the
  hardware failure or even an earthquake!




                     Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 QUICKSORT




              Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 QuickSort is a simple and efficient approach to
  sorting:
 Select an element m from unsorted array c and divide
  the array into two subarrays:
  csmall - elements smaller than m and
  clarge - elements larger than m.
 Recursively sort the subarrays and combine them
  together in sorted array csorted



                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
1.    QuickSort(c)
2.    if c consists of a single element
3.       return c
4.    m  c1
5.    Determine the set of elements csmall smaller
      than m
6.    Determine the set of elements clarge larger
      than m
7.    QuickSort(csmall)
8.    QuickSort(clarge)
9.    Combine csmall, m, and clarge into a single
      array, csorted
10.   return csorted

                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Runtime is based on our selection of m:

      -A good selection will split c evenly such that
       |csmall | = |clarge |, then the runtime is O(n log n).

      -For a good selection, the recurrence relation is:
             T(n) = 2T(n/2) + const ·n


  The time it takes to                    Time it takes to split the
  sort two smaller                        array into 2 parts where
  arrays of size n/2                      const is a positive constant
                     Kanishka Khandelwal-BCSE IV , JU   3/20/2012
However, a poor selection will split c unevenly and in the
 worst case, all elements will be greater or less than m
 so that one subarray is full and the other is empty. In
 this case, the runtime is O(n2).

For a poor selection, the recurrence relation is:
             T(n) = T(n-1) + const · n

The time it takes to sort                     Time it takes to split the array
one array containing n-1                      into 2 parts where const is a
elements                                      positive constant
                     Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 QuickSort seems like an ineffecient MergeSort
 To improve QuickSort, we need to choose m to be a
  good ‘splitter.’
 It can be proven that to achieve O(nlogn) running
  time, we don’t need a perfect split, just reasonably
  good one. In fact, if both subarrays are at least of size
  n/4, then running time will be O(n log n).
 This implies that half of the choices of m make good
  splitters.


                    Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 To improve QuickSort, randomly select m.
 Since half of the elements will be good splitters, if we
  choose m at random we will get a 50% chance that m
  will be a good choice.
 This approach will make sure that no matter what
  input is received, the expected running time is small.




                    Kanishka Khandelwal-BCSE IV , JU   3/20/2012
1. RandomizedQuickSort(c)
2. if c consists of a single element
3.     return c
4. Choose element m uniformly at random from c
5. Determine the set of elements csmall smaller
   than m
6. Determine the set of elements clarge larger than
     m
7. RandomizedQuickSort(csmall)
8. RandomizedQuickSort(clarge)
9. Combine csmall, m, and clarge into a single
    array, csorted
10. return csorted

                     Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Worst case runtime: O(m2)
 Expected runtime: O(m log m).
 Expected runtime is a good measure of the
 performance of randomized algorithms, often more
 informative than worst case runtimes.




                  Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Making a random choice is fast.
 An adversary is powerless; randomized algorithms
  have no worst case inputs.
 Randomized algorithms are often simpler and faster
  than their deterministic counterparts.




                   Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 In the worst case, a randomized algorithm may be very
  slow.
 There is a finite probability of getting incorrect answer.
 However, the probability of getting a wrong answer can
  be made arbitrarily small by the repeated employment
  of randomness.
 Getting true random numbers is almost impossible.




                    Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Assignments




  Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 Input: a set of 2D points
 Determine the closest pair (and its dist)
 Input points are stored in an array
 Suppose we have a strange storage data structure D :
 When we give a point to D, it stores the point and
  outputs the closest pair of points stored in D
 Our knowledge: Insertion time depends on whether
  the closest pair is changed or not.
 If output is the same: 1 clock tick
 If output is not the same: |D| clock ticks


                    Kanishka Khandelwal-BCSE IV , JU   3/20/2012
 With random insertion order,
 show that the expected total number of clock ticks
 used by D is O(n)




                  Kanishka Khandelwal-BCSE IV , JU   3/20/2012
Suppose you are given a directed graph with n vertices
and m unit-length edges. Consider the problem of
estimating the number of vertices within distance d of
each vertex. Give a fully polynomial approximation
scheme that solves this problem simultaneously for all
vertices for any fixed d.




                 Kanishka Khandelwal-BCSE IV , JU   3/20/2012

More Related Content

What's hot

Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rulesswapnac12
 
MACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHMMACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHMPuneet Kulyana
 
Neural Networks: Multilayer Perceptron
Neural Networks: Multilayer PerceptronNeural Networks: Multilayer Perceptron
Neural Networks: Multilayer PerceptronMostafa G. M. Mostafa
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic ReasoningJunya Tanaka
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Genetic algorithm ppt
Genetic algorithm pptGenetic algorithm ppt
Genetic algorithm pptMayank Jain
 
Genetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial IntelligenceGenetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial IntelligenceSahil Kumar
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networksAkash Goel
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityBhavin Darji
 
Genetic programming
Genetic programmingGenetic programming
Genetic programmingMeghna Singh
 
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEIntelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEKhushboo Pal
 
Artificial Neural Network Lect4 : Single Layer Perceptron Classifiers
Artificial Neural Network Lect4 : Single Layer Perceptron ClassifiersArtificial Neural Network Lect4 : Single Layer Perceptron Classifiers
Artificial Neural Network Lect4 : Single Layer Perceptron ClassifiersMohammed Bennamoun
 
Association rule mining
Association rule miningAssociation rule mining
Association rule miningAcad
 
Artificial Intelligence Notes Unit 1
Artificial Intelligence Notes Unit 1 Artificial Intelligence Notes Unit 1
Artificial Intelligence Notes Unit 1 DigiGurukul
 

What's hot (20)

Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rules
 
MACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHMMACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHM
 
Neural Networks: Multilayer Perceptron
Neural Networks: Multilayer PerceptronNeural Networks: Multilayer Perceptron
Neural Networks: Multilayer Perceptron
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic Reasoning
 
Basics of Soft Computing
Basics of Soft  Computing Basics of Soft  Computing
Basics of Soft Computing
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Genetic algorithm ppt
Genetic algorithm pptGenetic algorithm ppt
Genetic algorithm ppt
 
PAC Learning
PAC LearningPAC Learning
PAC Learning
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Genetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial IntelligenceGenetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial Intelligence
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networks
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
 
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEIntelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
 
Artificial Neural Network Lect4 : Single Layer Perceptron Classifiers
Artificial Neural Network Lect4 : Single Layer Perceptron ClassifiersArtificial Neural Network Lect4 : Single Layer Perceptron Classifiers
Artificial Neural Network Lect4 : Single Layer Perceptron Classifiers
 
Dempster shafer theory
Dempster shafer theoryDempster shafer theory
Dempster shafer theory
 
Association rule mining
Association rule miningAssociation rule mining
Association rule mining
 
Artificial Intelligence Notes Unit 1
Artificial Intelligence Notes Unit 1 Artificial Intelligence Notes Unit 1
Artificial Intelligence Notes Unit 1
 
N queen problem
N queen problemN queen problem
N queen problem
 

Similar to Randomized Algorithm

QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUSQUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUSJAMBIKA
 
Information Theoretic Co Clustering
Information Theoretic Co ClusteringInformation Theoretic Co Clustering
Information Theoretic Co ClusteringAllenWu
 
Histogram-Based Method for Effective Initialization of the K-Means Clustering...
Histogram-Based Method for Effective Initialization of the K-Means Clustering...Histogram-Based Method for Effective Initialization of the K-Means Clustering...
Histogram-Based Method for Effective Initialization of the K-Means Clustering...Gingles Caroline
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Modelkenluck2001
 
Cs105 l15-bucket radix
Cs105 l15-bucket radixCs105 l15-bucket radix
Cs105 l15-bucket radixGopi Saiteja
 
Stratified sampling and resampling for approximate Bayesian computation
Stratified sampling and resampling for approximate Bayesian computationStratified sampling and resampling for approximate Bayesian computation
Stratified sampling and resampling for approximate Bayesian computationUmberto Picchini
 
A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...
A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...
A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...Carrie Romero
 
K means Clustering
K means ClusteringK means Clustering
K means ClusteringEdureka!
 
3.2 partitioning methods
3.2 partitioning methods3.2 partitioning methods
3.2 partitioning methodsKrish_ver2
 
A Framework to Specify and Verify Computational Fields for Pervasive Computin...
A Framework to Specify and Verify Computational Fields for Pervasive Computin...A Framework to Specify and Verify Computational Fields for Pervasive Computin...
A Framework to Specify and Verify Computational Fields for Pervasive Computin...Danilo Pianini
 
Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...
Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...
Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...Wendy Belieu
 
Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...
Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...
Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...Chris Rackauckas
 
Optimising Data Using K-Means Clustering Algorithm
Optimising Data Using K-Means Clustering AlgorithmOptimising Data Using K-Means Clustering Algorithm
Optimising Data Using K-Means Clustering AlgorithmIJERA Editor
 
Initialization methods for the tsp with time windows using variable neighborh...
Initialization methods for the tsp with time windows using variable neighborh...Initialization methods for the tsp with time windows using variable neighborh...
Initialization methods for the tsp with time windows using variable neighborh...Konstantinos Giannakis
 
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sGreedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sJay Patel
 
Object Detection Beyond Mask R-CNN and RetinaNet III
Object Detection Beyond Mask R-CNN and RetinaNet IIIObject Detection Beyond Mask R-CNN and RetinaNet III
Object Detection Beyond Mask R-CNN and RetinaNet IIIWanjin Yu
 
A Minimum Spanning Tree Approach of Solving a Transportation Problem
A Minimum Spanning Tree Approach of Solving a Transportation ProblemA Minimum Spanning Tree Approach of Solving a Transportation Problem
A Minimum Spanning Tree Approach of Solving a Transportation Probleminventionjournals
 

Similar to Randomized Algorithm (20)

QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUSQUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
 
QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...
QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...
QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...
 
Information Theoretic Co Clustering
Information Theoretic Co ClusteringInformation Theoretic Co Clustering
Information Theoretic Co Clustering
 
Histogram-Based Method for Effective Initialization of the K-Means Clustering...
Histogram-Based Method for Effective Initialization of the K-Means Clustering...Histogram-Based Method for Effective Initialization of the K-Means Clustering...
Histogram-Based Method for Effective Initialization of the K-Means Clustering...
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Model
 
Cs105 l15-bucket radix
Cs105 l15-bucket radixCs105 l15-bucket radix
Cs105 l15-bucket radix
 
Stratified sampling and resampling for approximate Bayesian computation
Stratified sampling and resampling for approximate Bayesian computationStratified sampling and resampling for approximate Bayesian computation
Stratified sampling and resampling for approximate Bayesian computation
 
A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...
A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...
A Parallel Depth First Search Branch And Bound Algorithm For The Quadratic As...
 
K means Clustering
K means ClusteringK means Clustering
K means Clustering
 
Unit 2
Unit 2Unit 2
Unit 2
 
3.2 partitioning methods
3.2 partitioning methods3.2 partitioning methods
3.2 partitioning methods
 
A Framework to Specify and Verify Computational Fields for Pervasive Computin...
A Framework to Specify and Verify Computational Fields for Pervasive Computin...A Framework to Specify and Verify Computational Fields for Pervasive Computin...
A Framework to Specify and Verify Computational Fields for Pervasive Computin...
 
Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...
Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...
Analyzing The Quantum Annealing Approach For Solving Linear Least Squares Pro...
 
Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...
Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...
Generalizing Scientific Machine Learning and Differentiable Simulation Beyond...
 
Optimising Data Using K-Means Clustering Algorithm
Optimising Data Using K-Means Clustering AlgorithmOptimising Data Using K-Means Clustering Algorithm
Optimising Data Using K-Means Clustering Algorithm
 
Initialization methods for the tsp with time windows using variable neighborh...
Initialization methods for the tsp with time windows using variable neighborh...Initialization methods for the tsp with time windows using variable neighborh...
Initialization methods for the tsp with time windows using variable neighborh...
 
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sGreedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
 
Object Detection Beyond Mask R-CNN and RetinaNet III
Object Detection Beyond Mask R-CNN and RetinaNet IIIObject Detection Beyond Mask R-CNN and RetinaNet III
Object Detection Beyond Mask R-CNN and RetinaNet III
 
A Minimum Spanning Tree Approach of Solving a Transportation Problem
A Minimum Spanning Tree Approach of Solving a Transportation ProblemA Minimum Spanning Tree Approach of Solving a Transportation Problem
A Minimum Spanning Tree Approach of Solving a Transportation Problem
 
03 notes
03 notes03 notes
03 notes
 

Recently uploaded

week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 

Recently uploaded (20)

week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 

Randomized Algorithm

  • 2. Flip a coin An algorithm which flip coins is called a randomized algorithm. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 3. Making decisions could be complicated. A randomized algorithm is simpler. Consider the minimum cut problem Randomized algorithm? Pick a random edge and contract. And Continue until two vertices are left Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 4. Making good decisions could be expensive. A randomized algorithm is faster. Consider a sorting procedure. Picking an element in the middle makes the procedure very efficient, but it is expensive (i.e. linear time) to find such an element. 5 9 13 11 8 6 7 10 5 6 7 8 9 13 11 10 Picking a random element will do. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 5.  Avoid worst-case behavior: randomness can (probabilistically) guarantee average case behavior  Efficient approximate solutions to intractable problems  In many practical problems,we need to deal with HUGE input,and don’t even have time to read it once.But can we still do something useful? Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 6. Deterministic Input Output Computer Random Bits www.lavarnd.org (doesn’t use lava lamps anymore) Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 7.  Randomized algorithms make random rather than deterministic decisions.  The main advantage is that no input can reliably produce worst-case results because the algorithm runs differently each time.  These algorithms are commonly used in situations where no exact and fast algorithm is known.  Behavior can vary even on a fixed input. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 8.  Minimum spanning trees A linear time randomized algorithm, but no known linear time deterministic algorithm.  Primality testing A randomized polynomial time algorithm, but it takes thirty years to find a deterministic one.  Volume estimation of a convex body A randomized polynomial time approximation algorithm, but no known deterministic polynomial time approximation algorithm. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 9. Monte Carlo Las Vegas Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 10.  Always gives the true answer.  Running time is random.  Running time is variable whose expectation is bounded(say by a polynomail).  E.g. Randomized QuickSort Algorithm Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 11.  It may produce incorrect answer!  We are able to bound its probability.  By running it many times on independent random variables, we can make the failure probability arbitrarily small at the expense of running time.  E.g. Randomized Mincut Algorithm Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 12.  Suppose we want to find a number among n given numbers which is larger than or equal to the median. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 13. Suppose A1 < … < An. We want Ai, such that i ≥ n/2. It’s obvious that the best deterministic algorithm needs O(n) time to produce the answer. n may be very large! Suppose n is 100,000,000,000 ! Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 14.  Choose 100 of the numbers with equal probability.  find the maximum among these numbers.  Return the maximum. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 15.  The running time of the given algorithm is O(1).  The probability of Failure is 1/(2100).  Consider that the algorithm may return a wrong answer but the probability is very smaller than the hardware failure or even an earthquake! Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 16.  QUICKSORT Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 17.  QuickSort is a simple and efficient approach to sorting:  Select an element m from unsorted array c and divide the array into two subarrays: csmall - elements smaller than m and clarge - elements larger than m.  Recursively sort the subarrays and combine them together in sorted array csorted Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 18. 1. QuickSort(c) 2. if c consists of a single element 3. return c 4. m  c1 5. Determine the set of elements csmall smaller than m 6. Determine the set of elements clarge larger than m 7. QuickSort(csmall) 8. QuickSort(clarge) 9. Combine csmall, m, and clarge into a single array, csorted 10. return csorted Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 19.  Runtime is based on our selection of m: -A good selection will split c evenly such that |csmall | = |clarge |, then the runtime is O(n log n). -For a good selection, the recurrence relation is: T(n) = 2T(n/2) + const ·n The time it takes to Time it takes to split the sort two smaller array into 2 parts where arrays of size n/2 const is a positive constant Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 20. However, a poor selection will split c unevenly and in the worst case, all elements will be greater or less than m so that one subarray is full and the other is empty. In this case, the runtime is O(n2). For a poor selection, the recurrence relation is: T(n) = T(n-1) + const · n The time it takes to sort Time it takes to split the array one array containing n-1 into 2 parts where const is a elements positive constant Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 21.  QuickSort seems like an ineffecient MergeSort  To improve QuickSort, we need to choose m to be a good ‘splitter.’  It can be proven that to achieve O(nlogn) running time, we don’t need a perfect split, just reasonably good one. In fact, if both subarrays are at least of size n/4, then running time will be O(n log n).  This implies that half of the choices of m make good splitters. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 22.  To improve QuickSort, randomly select m.  Since half of the elements will be good splitters, if we choose m at random we will get a 50% chance that m will be a good choice.  This approach will make sure that no matter what input is received, the expected running time is small. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 23. 1. RandomizedQuickSort(c) 2. if c consists of a single element 3. return c 4. Choose element m uniformly at random from c 5. Determine the set of elements csmall smaller than m 6. Determine the set of elements clarge larger than m 7. RandomizedQuickSort(csmall) 8. RandomizedQuickSort(clarge) 9. Combine csmall, m, and clarge into a single array, csorted 10. return csorted Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 24.  Worst case runtime: O(m2)  Expected runtime: O(m log m).  Expected runtime is a good measure of the performance of randomized algorithms, often more informative than worst case runtimes. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 25.  Making a random choice is fast.  An adversary is powerless; randomized algorithms have no worst case inputs.  Randomized algorithms are often simpler and faster than their deterministic counterparts. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 26.  In the worst case, a randomized algorithm may be very slow.  There is a finite probability of getting incorrect answer.  However, the probability of getting a wrong answer can be made arbitrarily small by the repeated employment of randomness.  Getting true random numbers is almost impossible. Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 27. Assignments Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 28.  Input: a set of 2D points  Determine the closest pair (and its dist)  Input points are stored in an array  Suppose we have a strange storage data structure D :  When we give a point to D, it stores the point and outputs the closest pair of points stored in D  Our knowledge: Insertion time depends on whether the closest pair is changed or not.  If output is the same: 1 clock tick  If output is not the same: |D| clock ticks Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 29.  With random insertion order, show that the expected total number of clock ticks used by D is O(n) Kanishka Khandelwal-BCSE IV , JU 3/20/2012
  • 30. Suppose you are given a directed graph with n vertices and m unit-length edges. Consider the problem of estimating the number of vertices within distance d of each vertex. Give a fully polynomial approximation scheme that solves this problem simultaneously for all vertices for any fixed d. Kanishka Khandelwal-BCSE IV , JU 3/20/2012