時間複雜度請教 - 考試

Table of Contents

for i=0 to n do //是O(n+1)
begin
j=i; //這邊是O(n)嗎
while j >0 do j=j/2; //這邊寫在同一行,所以算O(log n)還是while判斷也要算?
end

謝謝

--

All Comments

James avatarJames2017-05-09
O(nlogn)是嗎?
Lauren avatarLauren2017-05-09
O(log n) 和(2log n)的差別是?建議原po再對big o 的定
義看一下@@ 以及O(n+1) 和 O(n)
Ida avatarIda2017-05-11
剛接觸這類問題 建議你把明確的總次數清楚算出來