Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

algorithm - Master's theorem with f(n)=log n

For master's theorem T(n) = a*T(n/b) + f(n) I am using 3 cases:

  1. If a*f(n/b) = c*f(n) for some constant c > 1 then T(n) = (n^log(b) a)
  2. If a*f(n/b) = f(n) then T(n) = (f(n) log(b) n)
  3. If a*f(n/b) = c*f(n) for some constant c < 1 then T(n) = (f(n))

But when f(n) = log n or n*log n, the value of c is dependent on value of n. How do I solve the recursive function using master's theorem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Usually, f(n) must be polynomial for the master theorem to apply - it doesn't apply for all functions. However, there is a limited "fourth case" for the master theorem, which allows it to apply to polylogarithmic functions.

If f(n) = O(nlogba logk n), then T(n) = O(nlogba log k+1 n).

In other words, suppose you have T(n) = 2T (n/2) + n log n. f(n) isn't a polynomial, but f(n)=n log n, and k = 1. Therefore, T(n) = O(n log2 n)

See this handout for more information: http://cse.unl.edu/~choueiry/S06-235/files/MasterTheorem-HandoutNoNotes.pdf


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...