27-6 Randomized multithreaded algorithms
Just as with ordinary serial algorithms, we sometimes want to implement randomized multithreaded algorithms. This problem explores how to adapt the various performance measures in order to handle the expected behavior of such algorithms. It also asks you to design and analyze a multithreaded algorithm for randomized quicksort.
a. Explain how to modify the work law \(\text{(27.2)}\), span law \(\text{(27.3)}\), and greedy scheduler bound \(\text{(27.4)}\) to work with expectations when \(T_P\), \(T_1\), and \(T_\infty\) are all random variables.
b. Consider a randomized multithreaded algorithm for which \(1\%\) of the time we have \(T_1 = 10^4\) and \(T_{10,000} = 1\), but for \(99\%\) of the time we have \(T_1 = T_{10,000} = 10^9\). Argue that the speedup of a randomized multithreaded algorithm should be defined as \(\text E[T_1]/\text E[T_P]\), rather than \(\text E[T_1 / T_P]\).
c. Argue that the parallelism of a randomized multithreaded algorithm should be defined as the ratio \(\text E[T_1] / \text E[T_\infty]\).
d. Multithread the \(\text{RANDOMIZED-QUICKSORT}\) algorithm on page 179 by using nested parallelism. (Do not parallelize \(\text{RANDOMIZED-PARTITION}\).) Give the pseudocode for your \(\text{P-RANDOMIZED-QUICKSORT}\) algorithm.
e. Analyze your multithreaded algorithm for randomized quicksort. (\(\textit{Hint:}\) Review the analysis of \(\text{RANDOMIZED-SELECT}\) on page 216.)
a.
b.
c. Same as the above.
d.
C++ | |
---|---|
1 2 3 4 5 6 |
|
e.
本页面的全部内容在 小熊老师 - 莆田青少年编程俱乐部 0594codes.cn 协议之条款下提供,附加条款亦可能应用