Algorithm
  • Introduction
  • Overview
    • 演算法漸進方法
    • BigO
  • Methods
    • Defining Methods
Powered by GitBook
On this page

Was this helpful?

  1. Overview

BigO

Previous演算法漸進方法NextDefining Methods

Last updated 4 years ago

Was this helpful?

我們在演算法中通常會用最差的時間複雜度來表示,也就是花費最久的可能時間。即為 BigO

然後 我們可以忽略掉過小的次方,例如 4n^2 + 2n 則時間複雜度為 O(n^2)

推導如下:

g(n)=4n+10,則g(n)可以用O(n)來表示,即f(n)=n
證明:g(n) ≦ c*f(n)
4n+10 ≦ cn  所以  (c-4)n ≧10
可以取c=5 且 n ≧ 10 且 N=10
所以只要c ≧ 5, n≧10時
4n+10 ≦ 5n

推薦閱讀:

http://lms.ctl.cyut.edu.tw/sys/read_attach.php?id=929422