[英]Create an algorithm whose recurrence is T(n) = T(n/3) + T(n/4) + O(n^2)
[英]algorithm find O(n) with two T(n) on the other side of the recurrence equation
接下來幾天我將參加算法考試,教授要求我們學習如何找到這種形式的O(n)方程式:
T(n) = T(n/3) + T(n/4) + 5n
T(n) = T(n/3) + 2T(n/4) + 5n
T(n) = T(n/3) + T(n/4) + 15n
T(n) = 2T(n/3) + T(n/4) + 4n
我知道如何使用主定理,但我懷疑我能在這里以某種方式使用它。 我的教授也沒有向我們展示如何解決這個問題的一個例子,在Google上我找不到太多(或者不知道如何找到解決方案 - 如何搜索它)所以有可能有人給我看如何逐步解決上述問題?
提前致謝。
PS:對不起可能錯誤的標題,正如我所說,我不知道如何呈現我想要的東西。
正如評論中所提到的,因為T(n/3) > T(n/4)
你可以找到上述每個方程的上界(這個條件適用於增加T(n)
)。
T(n) = T(n/3) + T(n/4) + 5n => T(n) < 2T(n/3) + 5n =>(using master theorem) T(n) = O(n)
另外,我們可以說T(n) = \\Theta(n)
因為5n
我們可以說T(n) = \\Omega(n)
。
T(n) = T(n/3) + 2T(n/4) + 5n => T(n) < 3T(n/3) + 5n =>(using master theorem) T(n) = O(nlog(n))
T(n) = T(n/3) + T(n/4) + 15n => T(n) < 2T(n/3) + 15n =>(using master theorem) T(n) = O(n)
T(n) = 2T(n/3) + T(n/4) + 4n => T(n) < 3T(n/3) + 4n =>(using master theorem) T(n) = O(nlog(n))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.