大å¦ã§ããå æ¸ã«ããå¦ã°ãªãã£ãOè¨æ³ã§ãããããã¢ã«ã´ãªãºã Cããç´ æ´ããããã¨åéãè¨ã£ã¦ããã®ã§ãåå¼·ãç´ãã¦ã¿ã¾ããã
ã¢ã«ã´ãªãºã Cã»æ°çâåºç¤ã»ãã¼ã¿æ§é ã»æ´åã»æ¢ç´¢
- ä½è : R.ã»ã¸ã¦ã£ãã¯,Robert Sedgewick,éä¸æµ©å¹³,æå®,ä½è¤åµ,ç°å£æ±
- åºç社/ã¡ã¼ã«ã¼: è¿ä»£ç§å¦ç¤¾
- çºå£²æ¥: 2004/06
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 2人 ã¯ãªãã¯: 57å
- ãã®ååãå«ãããã° (21件) ãè¦ã
å®ç¾©
é¢æ° g(N) ã O(f(N)) ã§ããã¨ã¯ãå®æ° c0 㨠N0 ãåå¨ãã¦ãN > N0 ã§ãããã¹ã¦ã® N ã«å¯¾ãã¦ãg(N) < c0 f(N) ãæãç«ã¤ãã¨ã§ããã
ãªãã»ã©ã(åããªã人ã¯ãO(f(N)) ããã¨ãã° O(log N)ã¨èªã¿æ¿ãã¦ã¿ã¾ãããã)
ãªããg(N) â O(f(N)) ã¨æ¸ãã®ãé©åã§ãããg(N) = O(f(N)) ã¨æ¸ãã®ãç¿æ £ã¨ãã¦å®çãã¦ãã¾ããå¾è¿°ããããã« Oè¨æ³ã¯ãããããçå¼ã®ããã«å¤å½¢ã§ããæ§è³ªãããã®ã§ãçå·ã§çµã¶æ¹ãç´æçã ããã§ãã
使ç¨ç®ç
- æ°å¼ã«ããã¦å°ããé ãç¡è¦ããæã«çãã誤差ã®éçã示ã
- ããã°ã©ã å ¨ä½ã®è§£æã«ã¯å½±é¿ã®å°ãªãé¨åãç¡è¦ããæã«çãã誤差ã®éçã示ã
- ç·å®è¡æéã®ä¸çã«ãã£ã¦ã¢ã«ã´ãªãºã ãåé¡ãã
æå¾ã®ç®çãããæèãã¦ãã¾ããã§ããã^^;
åºæ¬è¦å
Oè¨æ³ãå«ãæ°å¼ã«å¯¾ãã¦ã以ä¸ããã«å¤å½¢ã§ãã¾ãã証æã¯å¾è¿°ã
- f(N) â O(f(N))
- c O(f(N)) â O(f(N))
- O(cf(N)) â O(f(N))
- f(N) - g(N) = O(h(N)) â f(N) = g(N) + O(h(N))
- O(f(N)) O(g(N)) â O(f(N)g(N))
- g(N) = O(f(N)) ã®ã¨ããO(f(N)) + O(g(N)) â O(f(N))
ä¾
(N + O(1))(N + O(log N) + O(1)) = N^2 + O(N) + O(N log N) + O(log N) + O(N) + O(1) = N^2 + O(N log N)
ã¤ã¾ããN ã大ããã¨ãããã®å¼ã®è¿ä¼¼ã¯ N^2 ã§ããã誤差ã®éç㯠O(N log N) ã§ãã
証æ
以ä¸ã«é ã«åºæ¬è¦åã証æãã¾ãã
大åæã¨ãã¦ãN ⧠0, f(N) > 0 ã§ããc ãæ£æ°ã§ãã
f(N) â O(f(N))
1 ãã大ã㪠c ã«å¯¾ãã¦ãã©ã㪠N ã§ã f(N) < c f(N) ã¨ãªãã®ã§ãf(N) = O(f(N))ã
c O(f(N)) â O(f(N))
c O(f(N)) ã¨ã¯ãg(N) / c < c0 f(N) ã¨ãªã c0 㨠N0 ãåå¨ãããã¨ãæå³ããã
ãã®ã¨ããg(N) < c c0 f(N) ã§ãããN0 㨠c c0 ãåå¨ããã®ã§ãå³è¾ºã¯ O(f(N)) ã¨è¡¨ããã
ããªãã¡ãc O(f(N)) = O(f(N))ã
O(cf(N)) â O(f(N))
O(cf(N)) ã¨ã¯ãg(N) < c0 c f(N) ã¨ãªã c0 㨠N0 ãåå¨ãããã¨ãæå³ãããä¸è¨ã¨åæ§ã«ãO(cf(N)) = O(f(N))ã
f(N) - g(N) = O(h(N)) â f(N) = g(N) + O(h(N))
証æ1ï¼ã¢ã«ã´ãªãºã ã¤ã³ãããã¯ã·ã§ã³ã«ããã°ãf(N) = g(N) + O(h(N)) ã¨ã¯ãf(N) = g(N) + k(N) ã§ãããããªé¢æ° k(N) â O(h(N)) ãåå¨ããã¨ããæå³ã§ããã(a)
ä¸æ¹ãf(N) - g(N) = O(h(N)) ã¨ã¯ãf(N) - g(N) = k(N) ã¨ããã¨ãã« k(N) â O(h(N)) ã¨ããæå³ã§ããã(b)
(a) 㨠(b) ã®æå³ã¯ã¾ã£ããåãã§ããã
ã¢ã«ã´ãªãºã ã¤ã³ãããã¯ã·ã§ã³ 第1å·» æ°å¦çåºç¤ã¨ãã¼ã¿æ§é
- ä½è : T.ã³ã«ã¡ã³,R.ãªãã¹ã,C.ã©ã¤ã¶ã¼ã½ã³,Thomas H. Cormen,Ronald L. Rivest,Charles E. Leiserso,æµ éå²å¤«,æ¢ å°¾åå¸,åç°å¹¸ä¸,岩éåç,å±±ä¸é å²
- åºç社/ã¡ã¼ã«ã¼: è¿ä»£ç§å¦ç¤¾
- çºå£²æ¥: 1995/12
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 3人 ã¯ãªãã¯: 144å
- ãã®ååãå«ãããã° (34件) ãè¦ã
証æ2ï¼
f(N)=g(N)+O(h(N))ãæãç«ãã¤ã¨ããå®çã®ä¸»å¼µã¯ãâN1,âC,âN>N1,k(N)
f(N)-g(N)=O(h(N)) ãæãç«ã¤ã®ã§ãâN2,âD,âN>N2,f(N)-g(N)
N > max(N1,N2)ãæºããNã«ã¤ãã¦ãf(N)>=g(N)+Ck(N)>f(N)-Dk(N)+Ck(N)ã¨ãªããããã§ãf(N) > 0, k(N) > 0 ã§ãããE = C - D > 0 ã¨ãªã D 㨠C ãé¸ãã å ´åãf(N) > f(N) + E k(N) ã¨ãªãçç¾ããã
ãã£ã¦ãä»®å®ãééã£ã¦ãããf(N)=g(N)+O(h(N))ãæãç«ã¤ã
O(f(N)) O(g(N)) â O(f(N)g(N))
F(N) < c0 f(N) ã¨ãªã c0 㨠N0 ãåå¨ããã¾ããG(N) < c1 g(N) ã¨ãªã c1 㨠N1 ãåå¨ããã¨ãã2ã¤ã®å¼ãæãåãããã¨ãF(N)G(N) < c0 c1 f(N) g(N) ã¨ãªããããã¯ä¸çå·ãæºãã max(N0, N1) 㨠c0 c1 ãåå¨ãããã¨ãæå³ãã¦ãããããO(f(N)g(N)) ã¨æ¸ããã
g(N) = O(f(N)) ã®ã¨ããO(f(N)) + O(g(N)) â O(f(N))
æ¡ä»¶ã«ãããg(N) < c0 f(N) ãæºãã N0 㨠c0 ãåå¨ããã
F(N) < c1 f(N) ã¨ãªã c1 㨠N1 ãåå¨ããã¾ã G(N) < c2 g(N) ã¨ãªã c2 㨠N2 ãåå¨ããã¨ãã両辺ã足ãåãããã¨ãF(N) + G(N) < c1 f(N) + c2 g(N)ã
æ¡ä»¶ãããF(N) + G(N) < c1 f(N) + c0 c2 f(N) < (c1 + c0 c2) f(N)ãmax(N0, N1, N2) ã«å¯¾ãã¦ãc1 + c0 c2 ãåå¨ããã®ã§ãO(f(N)) ã¨æ¸ããã
æå¾ã«
証æã¯ã¤ãã¤ããªæããªã®ã§ãéæå¤æ´ãã¦è¡ãã¾ãã(_ _)