analysis techniques pasi fränti 19.9.2013. ordo o(g) – upper bound f(n) ≤ c∙g(n) omega ...

Download Analysis techniques Pasi Fränti 19.9.2013. Ordo O(g) – Upper Bound f(n) ≤ c∙g(n) Omega  (g)– Lower Bound f(n) ≥ c∙g(n) Theta Θ(g)– Exact limit: c 1 ∙g(n)

Post on 02-Jan-2016

212 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Analysis techniques19.9.2013

  • Ordo O(g) Upper Bound f(n) cg(n)Omega (g) Lower Bound f(n) cg(n)Theta (g) Exact limit: c1g(n) f(n) c2g(n)

    Upper and lower bounds

  • Upper limitUpper limit

    For example: f(n) = 3n-7 = O(n)Suppose that c= 4 then3n+7 4n 7 nwhich is true for all when n0=7

  • Lower limitLower limit

    Exact bounds

  • Example of boundsT(N)=N-7T(N)=(N)N0=1N0=8T(N)=O(N)

    Chart1

    00

    110.125

    220.25

    330.375

    440.5

    550.625

    660.75

    070.875

    181

    291.125

    3101.25

    4111.375

    5121.5

    6131.625

    7141.75

    8151.875

    9162

    10172.125

    11182.25

    12192.375

    13202.5

    14212.625

    15222.75

    16232.875

    17243

    18253.125

    19263.25

    20273.375

    21283.5

    22293.625

    23303.75

    24313.875

    25324

    26334.125

    27344.25

    28354.375

    29364.5

    30374.625

    31384.75

    32394.875

    33405

    34415.125

    35425.25

    36435.375

    37445.5

    38455.625

    39465.75

    40475.875

    41486

    42496.125

    43506.25

    44516.375

    45526.5

    46536.625

    47546.75

    48556.875

    49567

    50577.125

    51587.25

    52597.375

    53607.5

    54617.625

    55627.75

    56637.875

    57648

    58658.125

    59668.25

    60678.375

    61688.5

    62698.625

    63708.75

    64718.875

    65729

    66739.125

    67749.25

    68759.375

    69769.5

    70779.625

    71789.75

    72799.875

    738010

    748110.125

    758210.25

    768310.375

    778410.5

    788510.625

    798610.75

    808710.875

    818811

    828911.125

    839011.25

    849111.375

    859211.5

    869311.625

    879411.75

    889511.875

    899612

    909712.125

    919812.25

    929912.375

    9310012.5

    T(N)=N-7

    g1(N)=N

    g2(N)=N/8

    Sheet1

    00

    110.13

    220.25

    330.38

    440.50

    550.63

    660.75

    7070.88

    8181.00

    9291.13

    103101.25

    114111.38

    125121.50

    136131.63

    147141.75

    158151.88

    169162.00

    1710172.13

    1811182.25

    1912192.38

    2013202.50

    2114212.63

    2215222.75

    2316232.88

    2417243.00

    2518253.13

    2619263.25

    2720273.38

    2821283.50

    2922293.63

    3023303.75

    3124313.88

    3225324.00

    3326334.13

    3427344.25

    3528354.38

    3629364.50

    3730374.63

    3831384.75

    3932394.88

    4033405.00

    4134415.13

    4235425.25

    4336435.38

    4437445.50

    4538455.63

    4639465.75

    4740475.88

    4841486.00

    4942496.13

    5043506.25

    5144516.38

    5245526.50

    5346536.63

    5447546.75

    5548556.88

    5649567.00

    5750577.13

    5851587.25

    5952597.38

    6053607.50

    6154617.63

    6255627.75

    6356637.88

    6457648.00

    6558658.13

    6659668.25

    6760678.38

    6861688.50

    6962698.63

    7063708.75

    7164718.88

    7265729.00

    7366739.13

    7467749.25

    7568759.38

    7669769.50

    7770779.63

    7871789.75

    7972799.88

    80738010.00

    81748110.13

    82758210.25

    83768310.38

    84778410.50

    85788510.63

    86798610.75

    87808710.88

    88818811.00

    89828911.13

    90839011.25

    91849111.38

    92859211.50

    93869311.63

    94879411.75

    95889511.88

    96899612.00

    97909712.13

    98919812.25

    99929912.38

    1009310012.50

    Sheet1

    T(N)=N-7

    g1(N)=N

    g2(N)=N/8

    Sheet2

    Sheet3

  • Limit for polynomialsPolynomial function:Derivation of upper limit:

  • LogarithmDefinition:Properties:

  • Summations

  • Combinatory formulasPermutation:Binomial factor:

  • Lower bound for sorting

  • a
  • Theorem: The depth s of a binary tree with N leafs is s log2N

    Depth of a binary treesN leaf nodes

  • Initial case: For N=2, s = log2N=1Induction hypothesis: Trees of height s=k have at most N 2k leaves s log2NInduction step: Trees of height s=k+1 consists of one or two sub-trees of size k. Denote the number of leaf nodes as N1 and N2 .According to induction hypothesis, N1 2k and N2 2k. Number of leafs N = N1+N2 2k+2k = 2k+1. Hence, the hypothesis holds for k+1.

    Proof of the height

  • There are N! possible permutations, of which one is the list in sorted order. Tree has N! leaf nodes.It can be lower bounded

    Height of the tree is therefore bounded byProof of the lower bound

  • Stirlings formula

    More strict lower bound