查找递归算法的运行时间

问题描述

我正在尝试为该算法查找运行时(用于查找数组中的第 k 个最小值):

Select(A[1 . . . n],k) if n ≤ 100 then
  Return the k-th smallest element via brute-force; else
  Divide A into m ← ⌈n/3⌉ consecutive subgroups of size at most 3; 
  for i ← 1 . . . m do
    M[i] ← Median of the i-th subgroup;
  end
  p ← Select(M[1...m],⌊m/2⌋);
  Let B be an array contains all the elements < p in A;
  Let C be an array contains all the elements ≥ p in A;
  if len(B) ≥ k then
    return Select(B,k);
  else
    return Select(C,k − len(B));
  end
end

为了找到运行时,我试图提出一个递归关系。这就是我认为的:

由于算法对数组的 n/3 个元素进行递归调用,我预计它是 2T(n/3) + O(n)。然后应用大师定理。我的方向是否正确?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)