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
202 views
in Technique[技术] by (71.8m points)

sorting - Time complexity of median of medians algorithm

Hello I am taking Introduction to algorithm class this semeseter. However I have some problem in calculating time complexity of median of medians algorithm (here). I'm wondering how to get T(n)<=10cn from T(n)<=T(0.2n)+T(0.7n)+cn..

I think I cannot apply mater theorem to the expression above and wikipedia says I should use induction but I don't know How..

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

It is using induction. Assume for less than or equal n we have T(n) <= 10*c*n (we know the base of induction is true for equal or less than T(10) as they are constant and we can use large enough value for c). Now we want to prove this for T(n + 1). We know T(n + 1) <= T(0.2(n + 1)) + T(0.7( n + 1)) + c(n+1). From the assumption of the induction as 0.2(n + 1) and 0.7(n+1) is less than n (for n > 10), T(0.2(n + 1)) <= 10*c*0.2(n + 1) and T(0.7(n + 1)) <= 10*c*0.7(n + 1). Therefore, T(n+1) <= 2*c(n+1) + 7*c(n+1) + n*c = 10*c*n. The proof is completed!


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

...