首頁 > 後端開發 > C++ > 主體

高級主定理用於分治遞歸

王林
發布: 2023-08-31 21:09:17
轉載
915 人瀏覽過

高級主定理用於分治遞歸

分而治之 是一種基於遞歸地將問題分解為多個相似類型的子問題,並且這些子問題可以輕鬆解決的演算法。

範例

讓我們舉一個例子來更深入地了解分而治之的技巧-

function recursive(input x size n)
   if(n < k)
      Divide the input into m subproblems of size n/p.
      and call f recursively of each sub problem
   else
      Solve x and return
登入後複製

Combine the results of all subproblems and return the solution to the original problem.

Explanation − In the above problem, the problem set is to be subdivided into smaller subproblems that can be solved easily.

Masters Theorem for divide and conquer#ideide and conquer is an analysis theorem that can be used to determine a big-0 value for recursive relation algorithms. It is used to find the time required by the algorithm and represent it in repymptotic notation form. value of the problem in the above example −

T(n) = f(n) + m.T(n/p)
登入後複製

For most of the recursive algorithm, you will be able to find the Time complexity For the algorithm using the master's theorem, but there orare some cases master's theorem, but there not some cases master's theorem, not there not some cases not's theorem, not there not some cases not's theorem, not there not some cases not's theorem. applicable. These are the cases in which the master's theorem is not applicable. When the problem T(n) is not monotone, for example, T(n) = sin n. Problem function f(n) is not a polynomial.

##As the master theorem to find time complexity is not hot efficient in these cases, and advanced master theorem for recursive recurrence was designed. It is design to handle recurrence problem of the form −##rreee#是問題的規模。

a = 遞迴中的子問題數,a > 0

n/b = 每個子問題的規模 b > 1,k >= 0,p 是實數。

為了解決這種類型的問題,我們將使用以下解決方案:

如果a > b

k

,那麼T(n) = ∅ ( nlogba)

    如果a = b
  • k,那麼
  • 如果p > -1,那麼T(n) = ∅(nlogba log
  • p 1n)
      如果p = -1,那麼T(n) = ∅(nlog
    • ba loglogn)
    • 如果p ba)
  • 如果a k
  • ,那麼
如果p > = 0 ,那麼T(n)= ∅(n
  • klogp
      n)
    • 如果p
    • 使用高階主演算法,我們將計算一些演算法的複雜度−
  • 二分查找 − t(n) = θ( logn)

    歸併排序 − T(n) = θ(nlogn)

    以上是高級主定理用於分治遞歸的詳細內容。更多資訊請關注PHP中文網其他相關文章!

    相關標籤:
    來源:tutorialspoint.com
    本網站聲明
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
    最新問題
    熱門教學
    更多>
    最新下載
    更多>
    網站特效
    網站源碼
    網站素材
    前端模板
    關於我們 免責聲明 Sitemap
    PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!