Advanced Algorithms
RCPIT 2
RCPIT 3
RCPIT 4
RCPIT 5
RCPIT 6
RCPIT 7
RCPIT 8
RCPIT 9
RCPIT 10
RCPIT 11
RCPIT 12
Probabilistic Analysis
• To use Probabilistic Analysis, we need to understand the data and make certain
assumptions about the distribution of inputs in the data.
• We need to proceed with analysis and computation of average case running time but we
also need to manage the cost of hiring
• So let's start by giving certain priority or rank to the candidate
• We need to assume that candidates might appear in a random manner, which will lead to
uniform random permutation.
• So how many permutations we can have (n!)
• And each permutation have an equal probability to appear as a sequence for the interview.
• So, probabilistic analysis just works on the assumption that the candidates appear in a
random order of their rank or priority, but what if they are not.
• We can proceed with randomized algorithm to bring about more control.
13
Randomized Algorithm
• In average-case analysis, we often assume that all inputs are equally
likely
• Actuality, some inputs might be much more likely
• If we're really unlucky, the most likely inputs can be the most costly (as in
some implementations of quicksort)
• What can we do?
• Force all inputs to be equally likely, by randomizing the input
RCPIT 14
Randomization for Hiring Problem
• In the hire-assistant problem, we can first randomly permute the lists of
candidates, and then run the algorithm
• Then, for any input, we'd be guaranteed that the expected number of hires
would be in n + O(1)
• How can we randomly permute a list, so that every permutation is equally
as likely?
• That is, how can we shuffle a list, so that every permutation is equally
likely? Assume that we have a good random number generator.
• When the input is random, we refer to the running time as expected running
time
15
Indicator Random Variable
• It is method to convert between probabilities and expectation
• Indicator variable associated with event A:
• I{A} = 1, if A occurs
• I{A} = 0, if A does not occur
Example: Flip a coin: Y is a random variable representing the coin flip
• X = I{Y = H} = 1, if Y = Head
• X = I{Y = T} = 0, if Y = Tail
RCPIT 16
What is Expected Value? (IRV)
RCPIT 17
• Expected value E[] of a random variable
• Value you "expect" a random variable to have
• Average (mean) value of the variable over many trials
• Does not have to equal the value of any particular trial
Expected Value in IRV
RCPIT 18
RCPIT 19
IRV = Probability
RCPIT 20
IRV Ex. Coin Tossing
RCPIT 21
IRV ex for Hiring Problem
RCPIT 22
Expected Value in HIRING
RCPIT 23
RCPIT 24
RCPIT 25
RCPIT 26
RCPIT 27
For all n days
RCPIT 28
Indicator Random variable
RCPIT 29
Types of randomized algorithms
RCPIT 30
RCPIT 31
RCPIT 32
Las Vegas algorithm
RCPIT 33
Quick Sort- an example of las Vegas
RCPIT 34
RCPIT 35
Monte Carlo
RCPIT 36
Game theoretic randomized algorithm techniques (Min-Max) Technique
• It Follows the Backtracking Algo.
• Best Move Strategy is used.
• Max will try to Maximize its Utility (Best Move)
• Min will try to Minimize its Utility (Worst Move)
RCPIT 37

AA_Unit_2.pptx

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
    Probabilistic Analysis • Touse Probabilistic Analysis, we need to understand the data and make certain assumptions about the distribution of inputs in the data. • We need to proceed with analysis and computation of average case running time but we also need to manage the cost of hiring • So let's start by giving certain priority or rank to the candidate • We need to assume that candidates might appear in a random manner, which will lead to uniform random permutation. • So how many permutations we can have (n!) • And each permutation have an equal probability to appear as a sequence for the interview. • So, probabilistic analysis just works on the assumption that the candidates appear in a random order of their rank or priority, but what if they are not. • We can proceed with randomized algorithm to bring about more control. 13
  • 14.
    Randomized Algorithm • Inaverage-case analysis, we often assume that all inputs are equally likely • Actuality, some inputs might be much more likely • If we're really unlucky, the most likely inputs can be the most costly (as in some implementations of quicksort) • What can we do? • Force all inputs to be equally likely, by randomizing the input RCPIT 14
  • 15.
    Randomization for HiringProblem • In the hire-assistant problem, we can first randomly permute the lists of candidates, and then run the algorithm • Then, for any input, we'd be guaranteed that the expected number of hires would be in n + O(1) • How can we randomly permute a list, so that every permutation is equally as likely? • That is, how can we shuffle a list, so that every permutation is equally likely? Assume that we have a good random number generator. • When the input is random, we refer to the running time as expected running time 15
  • 16.
    Indicator Random Variable •It is method to convert between probabilities and expectation • Indicator variable associated with event A: • I{A} = 1, if A occurs • I{A} = 0, if A does not occur Example: Flip a coin: Y is a random variable representing the coin flip • X = I{Y = H} = 1, if Y = Head • X = I{Y = T} = 0, if Y = Tail RCPIT 16
  • 17.
    What is ExpectedValue? (IRV) RCPIT 17 • Expected value E[] of a random variable • Value you "expect" a random variable to have • Average (mean) value of the variable over many trials • Does not have to equal the value of any particular trial
  • 18.
    Expected Value inIRV RCPIT 18
  • 19.
  • 20.
  • 21.
    IRV Ex. CoinTossing RCPIT 21
  • 22.
    IRV ex forHiring Problem RCPIT 22
  • 23.
    Expected Value inHIRING RCPIT 23
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
    For all ndays RCPIT 28
  • 29.
  • 30.
    Types of randomizedalgorithms RCPIT 30
  • 31.
  • 32.
  • 33.
  • 34.
    Quick Sort- anexample of las Vegas RCPIT 34
  • 35.
  • 36.
  • 37.
    Game theoretic randomizedalgorithm techniques (Min-Max) Technique • It Follows the Backtracking Algo. • Best Move Strategy is used. • Max will try to Maximize its Utility (Best Move) • Min will try to Minimize its Utility (Worst Move) RCPIT 37