Re:I No Longer Need StackOverflow
by zaptheimpaler on Monday February 17, 2014 @10:54AM
(#7252596)
Well keep in mind that the inputs to the algorithm can vary. Randomization can help avoid a bad input from throwing your algorithm off. A simple example of how randomization helps is quicksort:
if we pick the pivot to always be the first element, then any sorted array will cause worst-case running time. But by randomizing the pivot, we can do well (in expectation) for any input.
if we pick the pivot to always be the first element, then any sorted array will cause worst-case running time. But by randomizing the pivot, we can do well (in expectation) for any input.