what is meaning expected value(math) and what reason behind it in quickSort?

浪尽此生 提交于 2019-12-12 03:22:44

问题


I need help interpreting the formulas from the Quicksort algorithm description in the Clrs book, page 157

My questions are overlayed in the page screenshot. This formula is about QiuckSort Algorithm.

  1. what is behind(logic) E[X] ... I mean what is happening in quickstart that the authors wrote this formula?
  2. given n=3, the result is 8, ok, but what does 8 mean semanitcally in quicksort?

回答1:


In order to understand the analysis in the book you cited, you need to understand some concepts from probability theory.

We want to determine the average number of comparisons made by quicksort.

We define some random variables. X_ij = 1 if z_i and z_j are compared, and 0 otherwise. X is a random variable for the total number of comparisons made. Thus X = sum over i and j of X_ij.

E[X] is the expected value of X, i.e. the value "on average". Expectation is linear, so the expectation of a sum is equal to the sum of expectations. That's how the book concludes that the average number of comparisons is equal to the sum over i and j of E[X_ij]. Since X_ij is either 0 or 1, its expected value is the same as the probability of making a comparison between z_i and z_j.

If you're still have trouble following this, you'll need to read up on probability, random variables, and expected values.



来源:https://stackoverflow.com/questions/58683766/what-is-meaning-expected-valuemath-and-what-reason-behind-it-in-quicksort

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!