algorithm - How do you determine the best, worse and average case complexity of a problem generated with random dice rolls? -


There is a picture book with 100 pages. If the dice is rolled randomly to select one of the pages and has been re-recorded for the search of a particular picture in the book - then how do I get the best, worst and average case complexity of this problem Decide?

Proposed Answer:

The best position: the picture is found on the first dice roll

The worst case: the picture is found on the 100th dice roll or The image does not exist

Average case: The figure is found after 50 dice rolls (= 100/2)

Perception: Incorrect images are searched at a time

Looking at your description of this problem, I do not think your assumption Picture only once "search "Is) is correct if you do not make that assumption, then the answer is shown below. You will see that the answers to the questions you offer are different.

  1. It is possible that you can succeed on the first attempt. Therefore, the first answer is 1.
  2. If you were unlucky, you could roll the wrong number forever. Then the second answer is infinite.
  3. The third question is less obvious.

What is the average number of rolls? You should know about: The number of trials required to achieve a single success.

  • Define P as a probability of a successful test; p = 0.01
  • P ( x = of ) is likely to be the first successful test k th after this we ( Of -1) will have to fail and achieve a success. Then verify PR (x = k) = (1- p ) ^ ( of -1) * p Verify that this wiki page (on the left column) " is.
  • Geometric distribution is 1 / p , hence the 100 is. This is the average number of rolls needed to find a specific image.

(Note: We need to consider 1 as a value less than zero, so use the column on the left side of 0 on the Wikipedia page.)

< / Div>

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -