[問題] 時間複雜度

看板Prob_Solve (計算數學 Problem Solving)作者 (喬巴)時間16年前 (2008/03/10 23:46), 編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/3 (看更多)
(一). begin sum = 0 for i = 1 to n do for j = 1 to n do sum = sum + 1 end 這題是 O(n^2) 嗎? (二). begin sum = 0 for i = 1 to n do begin j = n while j > 0 do begin sum = sum + 1 j = [j/2] end end end -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.116.194.95

03/10 23:49, , 1F
1.是 2.O(n lg n)
03/10 23:49, 1F

03/11 00:23, , 2F
可以講詳細一點嗎?
03/11 00:23, 2F

03/11 00:29, , 3F
看看SUM值跟N值關係就知道了 要學計算
03/11 00:29, 3F

03/11 00:30, , 4F
分析請參考master method or resursive tree
03/11 00:30, 4F
文章代碼(AID): #17rLVanR (Prob_Solve)
討論串 (同標題文章)
文章代碼(AID): #17rLVanR (Prob_Solve)