→ st84514:我覺得這樣寫應該是對的,應該是n<=0就回傳0吧! 01/27 19:36
沒看過的題目 請高手指教
Int RecursivesSum(int element[],int n)
{
If(n)
return(RecursiveSum(element,n-1)+element[n-1]);
return 0;
}
(a)Let the time complexity of this function is t(n).Please derive a recursive
formula for t(n) indicating the recurrence relation between t(n) and t(n-1).
(b)求 time complexity in θ notation.
想請問
RecursiveSum(element,n-1)+element[n-1]
^^^^^^^^^^
這是要怎麼寫到遞回方程式內
是T(n)=T(n-1)+n-1嗎?
且怎麼判斷 n=多少時 會結束遞回呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.69.54.7
※ 編輯: sroeud7l 來自: 210.69.54.7 (01/27 13:01)