23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

where bn is the time needed to partition a list for a given pivot <strong>and</strong> concatenate<br />

the result sublists after the recursive calls return. Show, by <strong>in</strong>duction, that T(n)<br />

is O(nlogn).<br />

C-11.8<br />

Modify <strong>in</strong>PlaceQuickSort (Code Fragment 11.6) to h<strong>and</strong>le the general case<br />

efficiently when the <strong>in</strong>put sequence, S, may have duplicate keys.<br />

C-11.9<br />

Describe a nonrecursive, <strong>in</strong>-place version of the quick-sort algorithm. The<br />

algorithm should still be based on the same divide-<strong>and</strong>-conquer approach, but<br />

use an explicit stack to process subproblems. Your algorithm should also<br />

guarantee the stack depth is at most O(logn).<br />

C-11.10<br />

Show that r<strong>and</strong>omized quick-sort runs <strong>in</strong> O(nlogn) time with probability at least<br />

1 − 1/n, that is, with high probability, by answer<strong>in</strong>g the follow<strong>in</strong>g:<br />

a.<br />

For ach <strong>in</strong>put element x, def<strong>in</strong>e Ci,j(x) to be a 0/1 r<strong>and</strong>om variable that is 1<br />

if <strong>and</strong> only if element x is <strong>in</strong> j + 1 subproblems that belong to size group i.<br />

Argue why we need not def<strong>in</strong>e Ci,j for j > n.<br />

b.<br />

Let Xi,j be a 0/1 r<strong>and</strong>om variable that is 1 with probability 1/2j, <strong>in</strong>dependent<br />

of any other events, <strong>and</strong> let L = …log 4/3 n…. Argue why<br />

c.<br />

.<br />

Show t the expected value of<br />

d.<br />

is at<br />

Show that the probability that<br />

most 1/n 2 us<strong>in</strong>g the<br />

Chernoff bound that states that if X is the sum of a f<strong>in</strong>ite number of<br />

<strong>in</strong>dependent 0/1 r<strong>and</strong>om variables with expected value μ > 0, then Pr(X ><br />

2……) < (4/e) −… , where e = 2.71828128....<br />

e.<br />

734

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!