题目
题目
单项选择题

Recr_Q_6 What is the recurrence relation for the quick_sort function given below  in the average case scenario as described below?

选项
A.T(n) =\begin{cases}\Theta(1) & \text{if } n < 2 \\2T\left(\frac{n}{2}\right) + \Theta(n \log n) & \text{otherwise}\end{cases}
B.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\2T\left(n-1\right) + \Theta(1) & \text{otherwise}\end{cases}
C.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\2T\left(\frac{n}{2}\right) + \Theta(n) & \text{otherwise}\end{cases}
D.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\T\left(n-1\right) + \Theta(1) & \text{otherwise}\end{cases}
E.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\T\left(n-1\right) + \Theta(n) & \text{otherwise}\end{cases}
F.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\T\left(\frac{n}{2}\right) + \Theta(1) & \text{otherwise}\end{cases}
查看解析

查看解析

标准答案
Please login to view
思路分析
We start by restating the problem to ensure clarity: determine the average-case recurrence relation for the quick_sort function described. Option 1: T(n) = { Θ(1) if n < 2; 2T(n/2) + Θ(n log n) otherwise }. - Why this is unlikely: the non-base-case term Θ(n log n) suggests that combining or partitioning costs grow as n log n, which is not the standard cost for partitioning in quicksort. In typical average-case analyses, the dominant work outside the recursive calls is the partitioning step, which is linear in n, not n log n. Therefore this option overestimates the combination cost and does not align with the classic average-case recurren......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!