[理工] 演算法 時間複雜度

看板Grad-ProbAsk作者 (還很新)時間7年前 (2016/07/26 15:05), 編輯推噓3(305)
留言8則, 4人參與, 最新討論串1/7 (看更多)
洪捷1-9 98年交大資工 We abuse the "+" operator with the asymptotic notations. For example, we may s ay that the total time for an algorithm is O(n)+θ(n). Which two of following statements are true. c.)O(nlogn)+θ(nlogn)=O(nlogn) 答案是說這個選項是FALSE,為什麼呢? 其中 b.)O(n^2)+θ(n^2)=θ(n^2) 這個選項是TRUE 那麽也肯定O(nlogn)+θ(nlogn)=θ(nlogn) 竟然滿足這個函式被bound在nlog,不也代表是O(nlogn)嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.136.51.18 ※ 文章網址: https://www.ptt.cc/bbs/Grad-ProbAsk/M.1469516726.A.027.html

07/26 15:22, , 1F
Which "two"
07/26 15:22, 1F

07/26 16:26, , 2F
看定義 θ(夾集) is more precise than O(upper bound)
07/26 16:26, 2F

07/26 16:26, , 3F
把定義寫出來並畫
07/26 16:26, 3F

07/26 16:26, , 4F
圖大概就可以知道它的直域 在四種可能中有三種共同
07/26 16:26, 4F

07/26 16:26, , 5F
落在theta剩餘一種不可能發生
07/26 16:26, 5F

07/26 17:23, , 6F
假設取f(n)=n^2 則係塔(nlogn)符合但O(nlogn)不符合
07/26 17:23, 6F

07/26 17:23, , 7F
若是往下取則有下限 係塔(nlogn)跟O(nlogn)都會符合
07/26 17:23, 7F

07/26 17:23, , 8F
所以相加會是係塔(nlogn)
07/26 17:23, 8F
文章代碼(AID): #1Nbmks0d (Grad-ProbAsk)
討論串 (同標題文章)
文章代碼(AID): #1Nbmks0d (Grad-ProbAsk)