1 / 22

CSE 2331/5331

CSE 2331/5331. Topic 5: Prob. Analysis Randomized Alg. Expected Complexity. Probabilistic method: Given a distribution for all possible inputs Derive expected time based on distribution Randomized algorithm: Add randomness in the algorithm

Download Presentation

CSE 2331/5331

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 2331/5331 Topic 5: Prob. Analysis Randomized Alg. CSE 2331/5331

  2. Expected Complexity • Probabilistic method: • Given a distribution for all possible inputs • Derive expected time based on distribution • Randomized algorithm: • Add randomness in the algorithm • Analyze the expected behavior of the algorithm CSE 2331/5331

  3. First Example • What is worst case time complexity? • What is expected / average time complexity? CSE 2331/5331

  4. Expected Running Time • Expected / average running time • = probability of event I • = running time given event I • To analyze, need to assume a probabilistic distribution for all inputs CSE 2331/5331

  5. SeqSearchAlg • Expected running time = • If we assume • = 0 • All permutations are equally likely • implies • Then expected running time = CSE 2331/5331

  6. Remarks • For probabilistic analysis • An input probabilistic distribution input model has be assumed! • For a fixed input, the running time is fixed. • The average / expected time complexity is for if we consider running it for a range of inputs, what the average behavior is. • Randomized algorithm • No assumption in input distribution! • Randomness is added in the algorithm • For a fixed input, the running time is NOT fixed. • The expected time is what we can expect when we run the algorithm on ANY SINGLE input. CSE 2331/5331

  7. Randomized Algorithms CSE 2331/5331

  8. Expectation • X is a random variable • The expectation of X is • E.g, coin flip • Linearity of expectation: • Conditional expectation: CSE 2331/5331

  9. Linearity of Expectation • = expected running time for func2 • What is ? + cn CSE 2331/5331

  10. Conditional Expectation • = expected running time of func2 • = expected running time of func3 • What is the expected running time of func1? CSE 2331/5331

  11. A Randomized Example Worst case complexity? Expected case? CSE 2331/5331

  12. Running Time Analysis • Worst Case: • Expected running time: CSE 2331/5331

  13. CSE 2331/5331

  14. Time Analysis • Worst case: • Expected running time: CSE 2331/5331

  15. A more complicated variation. CSE 2331/5331

  16. Analysis • Worst case: • Expected case: CSE 2331/5331

  17. An Example with Recursion CSE 2331/5331

  18. Worst case: • Expected running time • Solving this we have CSE 2331/5331

  19. Another Example with Recursion CSE 2331/5331

  20. Analysis • Worst case: • ! • Expected running time: • ! CSE 2331/5331

  21. Another Example CSE 2331/5331

  22. Analysis • Worst case: • Expected running time: CSE 2331/5331

More Related