Foundations of Computer Science Lecture 9 Sums And Asymptotics - - PowerPoint PPT Presentation

foundations of computer science lecture 9 sums and
SMART_READER_LITE
LIVE PREVIEW

Foundations of Computer Science Lecture 9 Sums And Asymptotics - - PowerPoint PPT Presentation

Foundations of Computer Science Lecture 9 Sums And Asymptotics Computing Sums Asymptotics: big-( ), big- O ( ), big-( ) The Integration Method ( 1) k +1 k 2 = ?? k 3 + 1 k =1 Last Time 1 Structural induction: proofs


slide-1
SLIDE 1

Foundations of Computer Science Lecture 9 Sums And Asymptotics

Computing Sums Asymptotics: big-Θ(·), big-O(·), big-Ω(·) The Integration Method

  • k=1

(−1)k+1k2 k3 + 1 = ??

slide-2
SLIDE 2

Last Time

1 Structural induction: proofs about recursively defined sets. ◮ Matched parentheses. ◮ N ◮ Palindromes. ◮ Arithmetic expressions. ◮ Rooted Binary Trees (RBT). Creator: Malik Magdon-Ismail Sums And Asymptotics: 2 / 16 Today →

slide-3
SLIDE 3

Today: Sums And Asymptotics

1

Maximum Substring Sum

2

Computing Sums

3

Asymptotics: Big-Theta, Big-Oh and Big-Omega

4

Integration Method

War Story. A startup asked me about their landing webpage. Users stay 1min, or 2min (about half as many), and so on. To “convert” the 10min user is very different from “converting” the 1 min user. Who should they tailor the webpage to?

Creator: Malik Magdon-Ismail Sums And Asymptotics: 3 / 16 Maximum Substring Sum →

slide-4
SLIDE 4

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-5
SLIDE 5

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

  • max. substring sum= 12

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-6
SLIDE 6

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

  • max. substring sum= 12

More generally, compute the maximum substring sum for

a1 a2 a3 a4 · · · an−1 an

(n measures the “size” of the input).

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-7
SLIDE 7

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

  • max. substring sum= 12

More generally, compute the maximum substring sum for

a1 a2 a3 a4 · · · an−1 an

(n measures the “size” of the input).

T1(n) = 2 +

n

  • i=1

 2 +

n

  • j=i

 5 +

j

  • k=i 2

   .

(3 for loops) (What does

n

  • i=1 mean: Pop Quiz 9.1)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-8
SLIDE 8

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

  • max. substring sum= 12

More generally, compute the maximum substring sum for

a1 a2 a3 a4 · · · an−1 an

(n measures the “size” of the input).

T1(n) = 2 +

n

  • i=1

 2 +

n

  • j=i

 5 +

j

  • k=i 2

   .

(3 for loops)

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 .

(2 for loops) (What does

n

  • i=1 mean: Pop Quiz 9.1)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-9
SLIDE 9

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

  • max. substring sum= 12

More generally, compute the maximum substring sum for

a1 a2 a3 a4 · · · an−1 an

(n measures the “size” of the input).

T1(n) = 2 +

n

  • i=1

 2 +

n

  • j=i

 5 +

j

  • k=i 2

   .

(3 for loops)

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 .

(2 for loops)

T3(n) =

                    

3 n = 1; 2T3(1

2n) + 6n + 9

n > 1 and even; T(1

2(n + 1)) + T(1 2(n − 1)) + 6n + 9

n > 1 and odd.

(recursive) (What does

n

  • i=1 mean: Pop Quiz 9.1)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-10
SLIDE 10

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

  • max. substring sum= 12

More generally, compute the maximum substring sum for

a1 a2 a3 a4 · · · an−1 an

(n measures the “size” of the input).

T1(n) = 2 +

n

  • i=1

 2 +

n

  • j=i

 5 +

j

  • k=i 2

   .

(3 for loops)

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 .

(2 for loops)

T3(n) =

                    

3 n = 1; 2T3(1

2n) + 6n + 9

n > 1 and even; T(1

2(n + 1)) + T(1 2(n − 1)) + 6n + 9

n > 1 and odd.

(recursive)

T4(n) = 5 +

n

  • i=1 10.

(1 for loops) (What does

n

  • i=1 mean: Pop Quiz 9.1)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-11
SLIDE 11

Maximum Substring Sum

1 −1 −1 2 3 4 −1 −1 2 3 −4 1 2 −1 −2 1

  • max. substring sum= 12

More generally, compute the maximum substring sum for

a1 a2 a3 a4 · · · an−1 an

(n measures the “size” of the input).

T1(n) = 2 +

n

  • i=1

 2 +

n

  • j=i

 5 +

j

  • k=i 2

   .

(3 for loops)

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 .

(2 for loops)

T3(n) =

                    

3 n = 1; 2T3(1

2n) + 6n + 9

n > 1 and even; T(1

2(n + 1)) + T(1 2(n − 1)) + 6n + 9

n > 1 and odd.

(recursive)

T4(n) = 5 +

n

  • i=1 10.

(1 for loops) (What does

n

  • i=1 mean: Pop Quiz 9.1)

Different algorithms have different runtime. Which is best?

Creator: Malik Magdon-Ismail Sums And Asymptotics: 4 / 16 Evaluate the Runtimes →

slide-12
SLIDE 12

Evaluate the Runtimes

T1(n) = 2 +

n

  • i=1
  • 2 +

n

  • j=i
  • 5 +

j

  • k=i

2

  • .

n

1 2 3 4 5 6 7 8 9 10

T1(n)

11 29 58 100 157 231 324 438 575 737

Creator: Malik Magdon-Ismail Sums And Asymptotics: 5 / 16 Constant Rule →

slide-13
SLIDE 13

Evaluate the Runtimes

T1(n) = 2 +

n

  • i=1
  • 2 +

n

  • j=i
  • 5 +

j

  • k=i

2

  • .

T2(n) = 2 +

n

  • i=1
  • 3 +

n

  • j=i

6

  • n

1 2 3 4 5 6 7 8 9 10

T1(n)

11 29 58 100 157 231 324 438 575 737

T2(n)

11 26 47 74 107 146 191 242 299 362

T2 is better than T1;

Creator: Malik Magdon-Ismail Sums And Asymptotics: 5 / 16 Constant Rule →

slide-14
SLIDE 14

Evaluate the Runtimes

T1(n) = 2 +

n

  • i=1
  • 2 +

n

  • j=i
  • 5 +

j

  • k=i

2

  • .

T2(n) = 2 +

n

  • i=1
  • 3 +

n

  • j=i

6

  • T3(n) =

   3 n = 1; 2T3( 1

2n) + 6n + 9

n > 1 and even; T ( 1

2(n + 1)) + T ( 1 2(n − 1)) + 6n + 9

n > 1 and odd.

n

1 2 3 4 5 6 7 8 9 10

T1(n)

11 29 58 100 157 231 324 438 575 737

T2(n)

11 26 47 74 107 146 191 242 299 362

T3(n)

3 27 57 87 123 159 195 231 273 315

T2 is better than T1; T2 versus T3???

Creator: Malik Magdon-Ismail Sums And Asymptotics: 5 / 16 Constant Rule →

slide-15
SLIDE 15

Evaluate the Runtimes

T1(n) = 2 +

n

  • i=1
  • 2 +

n

  • j=i
  • 5 +

j

  • k=i

2

  • .

T2(n) = 2 +

n

  • i=1
  • 3 +

n

  • j=i

6

  • T3(n) =

   3 n = 1; 2T3( 1

2n) + 6n + 9

n > 1 and even; T ( 1

2(n + 1)) + T ( 1 2(n − 1)) + 6n + 9

n > 1 and odd. T4(n) = 5 +

n

  • i=1

10

n

1 2 3 4 5 6 7 8 9 10

T1(n)

11 29 58 100 157 231 324 438 575 737

T2(n)

11 26 47 74 107 146 191 242 299 362

T3(n)

3 27 57 87 123 159 195 231 273 315

T4(n)

15 25 35 45 55 65 75 85 95 105

T2 is better than T1; T2 versus T3???

What about T4?

Creator: Malik Magdon-Ismail Sums And Asymptotics: 5 / 16 Constant Rule →

slide-16
SLIDE 16

Evaluate the Runtimes

T1(n) = 2 +

n

  • i=1
  • 2 +

n

  • j=i
  • 5 +

j

  • k=i

2

  • .

T2(n) = 2 +

n

  • i=1
  • 3 +

n

  • j=i

6

  • T3(n) =

   3 n = 1; 2T3( 1

2n) + 6n + 9

n > 1 and even; T ( 1

2(n + 1)) + T ( 1 2(n − 1)) + 6n + 9

n > 1 and odd. T4(n) = 5 +

n

  • i=1

10

n

1 2 3 4 5 6 7 8 9 10

T1(n)

11 29 58 100 157 231 324 438 575 737

T2(n)

11 26 47 74 107 146 191 242 299 362

T3(n)

3 27 57 87 123 159 195 231 273 315

T4(n)

15 25 35 45 55 65 75 85 95 105

T2 is better than T1; T2 versus T3???

What about T4? We need:

1 Simple formulas for T1(n), . . . , T4(n): we need to compute sums and solve recurrences. Creator: Malik Magdon-Ismail Sums And Asymptotics: 5 / 16 Constant Rule →

slide-17
SLIDE 17

Evaluate the Runtimes

T1(n) = 2 +

n

  • i=1
  • 2 +

n

  • j=i
  • 5 +

j

  • k=i

2

  • .

T2(n) = 2 +

n

  • i=1
  • 3 +

n

  • j=i

6

  • T3(n) =

   3 n = 1; 2T3( 1

2n) + 6n + 9

n > 1 and even; T ( 1

2(n + 1)) + T ( 1 2(n − 1)) + 6n + 9

n > 1 and odd. T4(n) = 5 +

n

  • i=1

10

n

1 2 3 4 5 6 7 8 9 10

T1(n)

11 29 58 100 157 231 324 438 575 737

T2(n)

11 26 47 74 107 146 191 242 299 362

T3(n)

3 27 57 87 123 159 195 231 273 315

T4(n)

15 25 35 45 55 65 75 85 95 105

T2 is better than T1; T2 versus T3???

What about T4? We need:

1 Simple formulas for T1(n), . . . , T4(n): we need to compute sums and solve recurrences. 2 A way to compare runtime-functions that captures the essence of the algorithm. Creator: Malik Magdon-Ismail Sums And Asymptotics: 5 / 16 Constant Rule →

slide-18
SLIDE 18

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-19
SLIDE 19

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-20
SLIDE 20

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-21
SLIDE 21

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-22
SLIDE 22

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-23
SLIDE 23

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

j × 10

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-24
SLIDE 24

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

j × 10 S3 =

10

  • i=1 i

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-25
SLIDE 25

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

j × 10 S3 =

10

  • i=1 i = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-26
SLIDE 26

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

j × 10 S3 =

10

  • i=1 i = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

1 2 × 10 × (10 + 1)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-27
SLIDE 27

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

j × 10 S3 =

10

  • i=1 i = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

1 2 × 10 × (10 + 1)

The index of summation is i in these examples.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-28
SLIDE 28

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

j × 10 S3 =

10

  • i=1 i = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

1 2 × 10 × (10 + 1)

The index of summation is i in these examples. Constants (independent of summation index) can be taken outside the sum.

S1 =

10

  • i=1 3 = 3

10

  • i=1 1 = 3 × 10

S2 =

10

  • i=1 j = j

10

  • i=1 1 = j × 10.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-29
SLIDE 29

Computing Sums: Tool 1: Constant Rule

S1 =

10

  • i=1 3 = 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3

3 × 10 S2 =

10

  • i=1 j = j + j + j + j + j + j + j + j + j + j

j × 10 S3 =

10

  • i=1 i = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

1 2 × 10 × (10 + 1)

The index of summation is i in these examples. Constants (independent of summation index) can be taken outside the sum.

S1 =

10

  • i=1 3 = 3

10

  • i=1 1 = 3 × 10

S2 =

10

  • i=1 j = j

10

  • i=1 1 = j × 10.

Pop Quiz 9.2 Compute T4(n) = 5 +

n

  • i=1 10.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 6 / 16 Addition Rule →

slide-30
SLIDE 30

Computing Sums: Tool 2: Addition Rule

S =

5

  • i=1(i + i2)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 7 / 16 Common Sums →

slide-31
SLIDE 31

Computing Sums: Tool 2: Addition Rule

S =

5

  • i=1(i + i2)

= (1 + 12) + (2 + 22) + (3 + 32) + (4 + 42) + (5 + 52)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 7 / 16 Common Sums →

slide-32
SLIDE 32

Computing Sums: Tool 2: Addition Rule

S =

5

  • i=1(i + i2)

= (1 + 12) + (2 + 22) + (3 + 32) + (4 + 42) + (5 + 52) = (1 + 2 + 3 + 4 + 5) + (12 + 22 + 32 + 42 + 52)

(rearrange terms)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 7 / 16 Common Sums →

slide-33
SLIDE 33

Computing Sums: Tool 2: Addition Rule

S =

5

  • i=1(i + i2)

= (1 + 12) + (2 + 22) + (3 + 32) + (4 + 42) + (5 + 52) = (1 + 2 + 3 + 4 + 5) + (12 + 22 + 32 + 42 + 52)

(rearrange terms)

=

5

  • i=1 i +

5

  • i=1 i2.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 7 / 16 Common Sums →

slide-34
SLIDE 34

Computing Sums: Tool 2: Addition Rule

S =

5

  • i=1(i + i2)

= (1 + 12) + (2 + 22) + (3 + 32) + (4 + 42) + (5 + 52) = (1 + 2 + 3 + 4 + 5) + (12 + 22 + 32 + 42 + 52)

(rearrange terms)

=

5

  • i=1 i +

5

  • i=1 i2.

The sum of terms added together is the addition of the individual sums.

  • i (a(i) + b(i) + c(i) + · · · ) =
  • i a(i) +
  • i b(i) +
  • i c(i) + · · ·

Creator: Malik Magdon-Ismail Sums And Asymptotics: 7 / 16 Common Sums →

slide-35
SLIDE 35

Computing Sums: Tool 3: Common Sums

n

  • i=k 1 = n + 1 − k

n

  • i=1 f(x) = nf(x)

n

  • i=0 ri = 1 − rn+1

1 − r (r=1)

n

  • i=1 i =

1 2n(n + 1) n

  • i=1 i2 =

1 6n(n + 1)(2n + 1) n

  • i=1 i3 =

1 4n2(n + 1)2 n

  • i=0 2i = 2n+1 − 1

n

  • i=0

1 2i = 2 − 1 2n

n

  • i=1 log i = log n!

Example:

n

  • i=1(1 + 2i + 2i+2)

n

  • i=1(1 + 2i + 2i+2) =

Creator: Malik Magdon-Ismail Sums And Asymptotics: 8 / 16 Nested Sums →

slide-36
SLIDE 36

Computing Sums: Tool 3: Common Sums

n

  • i=k 1 = n + 1 − k

n

  • i=1 f(x) = nf(x)

n

  • i=0 ri = 1 − rn+1

1 − r (r=1)

n

  • i=1 i =

1 2n(n + 1) n

  • i=1 i2 =

1 6n(n + 1)(2n + 1) n

  • i=1 i3 =

1 4n2(n + 1)2 n

  • i=0 2i = 2n+1 − 1

n

  • i=0

1 2i = 2 − 1 2n

n

  • i=1 log i = log n!

Example:

n

  • i=1(1 + 2i + 2i+2)

n

  • i=1(1 + 2i + 2i+2) =

n

  • i=1 1 +

n

  • i=1 2i +

n

  • i=1 2i+2

(addition rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 8 / 16 Nested Sums →

slide-37
SLIDE 37

Computing Sums: Tool 3: Common Sums

n

  • i=k 1 = n + 1 − k

n

  • i=1 f(x) = nf(x)

n

  • i=0 ri = 1 − rn+1

1 − r (r=1)

n

  • i=1 i =

1 2n(n + 1) n

  • i=1 i2 =

1 6n(n + 1)(2n + 1) n

  • i=1 i3 =

1 4n2(n + 1)2 n

  • i=0 2i = 2n+1 − 1

n

  • i=0

1 2i = 2 − 1 2n

n

  • i=1 log i = log n!

Example:

n

  • i=1(1 + 2i + 2i+2)

n

  • i=1(1 + 2i + 2i+2) =

n

  • i=1 1 +

n

  • i=1 2i +

n

  • i=1 2i+2

(addition rule)

=

n

  • i=1 1 + 2

n

  • i=1 i + 4

n

  • i=1 2i

(constant rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 8 / 16 Nested Sums →

slide-38
SLIDE 38

Computing Sums: Tool 3: Common Sums

n

  • i=k 1 = n + 1 − k

n

  • i=1 f(x) = nf(x)

n

  • i=0 ri = 1 − rn+1

1 − r (r=1)

n

  • i=1 i =

1 2n(n + 1) n

  • i=1 i2 =

1 6n(n + 1)(2n + 1) n

  • i=1 i3 =

1 4n2(n + 1)2 n

  • i=0 2i = 2n+1 − 1

n

  • i=0

1 2i = 2 − 1 2n

n

  • i=1 log i = log n!

Example:

n

  • i=1(1 + 2i + 2i+2)

n

  • i=1(1 + 2i + 2i+2) =

n

  • i=1 1 +

n

  • i=1 2i +

n

  • i=1 2i+2

(addition rule)

=

n

  • i=1 1 + 2

n

  • i=1 i + 4

n

  • i=1 2i

(constant rule)

= n + 2 × 1

2n(n + 1) + 4 · (2n+1 − 1−1)

(common sums)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 8 / 16 Nested Sums →

slide-39
SLIDE 39

Computing Sums: Tool 3: Common Sums

n

  • i=k 1 = n + 1 − k

n

  • i=1 f(x) = nf(x)

n

  • i=0 ri = 1 − rn+1

1 − r (r=1)

n

  • i=1 i =

1 2n(n + 1) n

  • i=1 i2 =

1 6n(n + 1)(2n + 1) n

  • i=1 i3 =

1 4n2(n + 1)2 n

  • i=0 2i = 2n+1 − 1

n

  • i=0

1 2i = 2 − 1 2n

n

  • i=1 log i = log n!

Example:

n

  • i=1(1 + 2i + 2i+2)

n

  • i=1(1 + 2i + 2i+2) =

n

  • i=1 1 +

n

  • i=1 2i +

n

  • i=1 2i+2

(addition rule)

=

n

  • i=1 1 + 2

n

  • i=1 i + 4

n

  • i=1 2i

(constant rule)

= n + 2 × 1

2n(n + 1) + 4 · (2n+1 − 1−1)

(common sums)

= n + n(n + 1) + 2n+3 − 8

(common sums)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 8 / 16 Nested Sums →

slide-40
SLIDE 40

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-41
SLIDE 41

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-42
SLIDE 42

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1

3

  • j=1 1

3

  • j=1 1

3

  • j=1 1

(i=1) (i=2) (i=3)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-43
SLIDE 43

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-44
SLIDE 44

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-45
SLIDE 45

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9. S2

1

  • j=1 1

2

  • j=1 1

3

  • j=1 1

(i=1) (i=2) (i=3)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-46
SLIDE 46

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9. S2 =

1

  • j=1 1 +

2

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-47
SLIDE 47

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9. S2 =

1

  • j=1 1 +

2

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 1 + 2 + 3 = 6.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-48
SLIDE 48

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9. S2 =

1

  • j=1 1 +

2

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 1 + 2 + 3 = 6.

More generally:

S(n) =

n

  • i=1

i

  • j=1 1

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-49
SLIDE 49

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9. S2 =

1

  • j=1 1 +

2

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 1 + 2 + 3 = 6.

More generally:

S(n) =

n

  • i=1

i

  • j=1 1 =

n

  • i=1

i

  • j=1 1

f(i)=i

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-50
SLIDE 50

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9. S2 =

1

  • j=1 1 +

2

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 1 + 2 + 3 = 6.

More generally:

S(n) =

n

  • i=1

i

  • j=1 1 =

n

  • i=1

i

  • j=1 1

f(i)=i

=

n

  • i=1 i

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-51
SLIDE 51

Computing Sums: Tool 3: Nested Sum Rule

S1 =

3

  • i=1

3

  • j=1 1;

S2 =

3

  • i=1

i

  • j=1 1.

To compute a nested sum, start with the innermost sum and proceed outward.

S1 =

3

  • j=1 1 +

3

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 3 + 3 + 3 = 9. S2 =

1

  • j=1 1 +

2

  • j=1 1 +

3

  • j=1 1

(i=1) (i=2) (i=3)

= 1 + 2 + 3 = 6.

More generally:

S(n) =

n

  • i=1

i

  • j=1 1 =

n

  • i=1

i

  • j=1 1

f(i)=i

=

n

  • i=1 i = 1

2n(n + 1).

Creator: Malik Magdon-Ismail Sums And Asymptotics: 9 / 16 Computing T2(n) →

slide-52
SLIDE 52

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-53
SLIDE 53

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-54
SLIDE 54

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-55
SLIDE 55

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(common sum)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-56
SLIDE 56

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(common sum)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(innermost sum)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-57
SLIDE 57

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(common sum)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(innermost sum)

= 2 + 3n + 6

n

  • i=1

n

  • j=i 1

(constant rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-58
SLIDE 58

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(common sum)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(innermost sum)

= 2 + 3n + 6

n

  • i=1

n

  • j=i 1

(constant rule)

= 2 + 3n + 6

n

  • i=1 (n + 1 − i)

(common sum)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-59
SLIDE 59

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(common sum)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(innermost sum)

= 2 + 3n + 6

n

  • i=1

n

  • j=i 1

(constant rule)

= 2 + 3n + 6

n

  • i=1 (n + 1 − i)

(common sum)

= 2 + 3n + 6(n + (n − 1) + · · · + 1)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-60
SLIDE 60

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(common sum)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(innermost sum)

= 2 + 3n + 6

n

  • i=1

n

  • j=i 1

(constant rule)

= 2 + 3n + 6

n

  • i=1 (n + 1 − i)

(common sum)

= 2 + 3n + 6(n + (n − 1) + · · · + 1) = 2 + 3n + 6 × 1

2n(n + 1)

(common sum)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-61
SLIDE 61

Computing a Formula for T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

 

T2(n) = 2 +

n

  • i=1

 3 +

n

  • j=i 6

  = 2 +

n

  • i=1 3 +

n

  • i=1

n

  • j=i 6

(sum rule)

= 2 + 3

n

  • i=1 1 +

n

  • i=1

n

  • j=i 6

(constant rule)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(common sum)

= 2 + 3n +

n

  • i=1

n

  • j=i 6

(innermost sum)

= 2 + 3n + 6

n

  • i=1

n

  • j=i 1

(constant rule)

= 2 + 3n + 6

n

  • i=1 (n + 1 − i)

(common sum)

= 2 + 3n + 6(n + (n − 1) + · · · + 1) = 2 + 3n + 6 × 1

2n(n + 1)

(common sum)

= 2 + 6n + 3n2

(algebra)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 10 / 16 Practice →

slide-62
SLIDE 62

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-63
SLIDE 63

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

n

  • i=1

i

  • j=1 ij

(innermost sum)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-64
SLIDE 64

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

n

  • i=1

i

  • j=1 ij

(innermost sum)

=

n

  • i=1 i

i

  • j=1 j

(constant rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-65
SLIDE 65

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

n

  • i=1

i

  • j=1 ij

(innermost sum)

=

n

  • i=1 i

i

  • j=1 j

(constant rule)

=

n

  • i=1 i × 1

2i(i + 1)

(common sum)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-66
SLIDE 66

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

n

  • i=1

i

  • j=1 ij

(innermost sum)

=

n

  • i=1 i

i

  • j=1 j

(constant rule)

=

n

  • i=1 i × 1

2i(i + 1)

(common sum)

=

1 2 n

  • i=1(i3 + i2)

(algebra, constant rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-67
SLIDE 67

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

n

  • i=1

i

  • j=1 ij

(innermost sum)

=

n

  • i=1 i

i

  • j=1 j

(constant rule)

=

n

  • i=1 i × 1

2i(i + 1)

(common sum)

=

1 2 n

  • i=1(i3 + i2)

(algebra, constant rule)

=

1 2 n

  • i=1 i3 + 1

2 n

  • i=1 i2

(sum rule)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-68
SLIDE 68

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

n

  • i=1

i

  • j=1 ij

(innermost sum)

=

n

  • i=1 i

i

  • j=1 j

(constant rule)

=

n

  • i=1 i × 1

2i(i + 1)

(common sum)

=

1 2 n

  • i=1(i3 + i2)

(algebra, constant rule)

=

1 2 n

  • i=1 i3 + 1

2 n

  • i=1 i2

(sum rule)

=

1 8n2(n + 1)2 + 1 12n(n + 1)(2n + 1)

(common sums)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-69
SLIDE 69

Practice: Compute a Formula for the Sum

n

  • i=1

i

  • j=1 ij

n

  • i=1

i

  • j=1 ij =

n

  • i=1

i

  • j=1 ij

(innermost sum)

=

n

  • i=1 i

i

  • j=1 j

(constant rule)

=

n

  • i=1 i × 1

2i(i + 1)

(common sum)

=

1 2 n

  • i=1(i3 + i2)

(algebra, constant rule)

=

1 2 n

  • i=1 i3 + 1

2 n

  • i=1 i2

(sum rule)

=

1 8n2(n + 1)2 + 1 12n(n + 1)(2n + 1)

(common sums)

=

1 12n + 3 8n2 + 5 12n3 + 1 8n4

(algebra)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 11 / 16 Summary of Max. Substring Sum →

slide-70
SLIDE 70

Summary of Maximum Substring Sum Algorithms

Runtimes T1(n) = 2 + 31

6 n + 7 2n2 + 1 3n3

T2(n) = 2 + 6n + 3n2

3n(log2 n + 1) − 9 ≤ T3(n) ≤ 12n(log2 n + 3) − 9

T4(n) = 5 + 10n

(“simple” formulas for T1(n), . . . , T4(n))

n (Running Time)/n T1(n) T2(n) T3(n) T4(n) 10 20 30 40 50 20 40 60 80 100

Creator: Malik Magdon-Ismail Sums And Asymptotics: 12 / 16 Linear Functions Θ(n) →

slide-71
SLIDE 71

Summary of Maximum Substring Sum Algorithms

Runtimes T1(n) = 2 + 31

6 n + 7 2n2 + 1 3n3

T2(n) = 2 + 6n + 3n2

3n(log2 n + 1) − 9 ≤ T3(n) ≤ 12n(log2 n + 3) − 9

T4(n) = 5 + 10n

(“simple” formulas for T1(n), . . . , T4(n))

n (Running Time)/n T1(n) T2(n) T3(n) T4(n) 10 20 30 40 50 20 40 60 80 100

So, which algorithm is best?

Creator: Malik Magdon-Ismail Sums And Asymptotics: 12 / 16 Linear Functions Θ(n) →

slide-72
SLIDE 72

Summary of Maximum Substring Sum Algorithms

Runtimes T1(n) = 2 + 31

6 n + 7 2n2 + 1 3n3

T2(n) = 2 + 6n + 3n2

3n(log2 n + 1) − 9 ≤ T3(n) ≤ 12n(log2 n + 3) − 9

T4(n) = 5 + 10n

(“simple” formulas for T1(n), . . . , T4(n))

n (Running Time)/n T1(n) T2(n) T3(n) T4(n) 10 20 30 40 50 20 40 60 80 100

So, which algorithm is best? Computers solve problems with big inputs. We care about large n.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 12 / 16 Linear Functions Θ(n) →

slide-73
SLIDE 73

Summary of Maximum Substring Sum Algorithms

Runtimes T1(n) = 2 + 31

6 n + 7 2n2 + 1 3n3

T2(n) = 2 + 6n + 3n2

3n(log2 n + 1) − 9 ≤ T3(n) ≤ 12n(log2 n + 3) − 9

T4(n) = 5 + 10n

(“simple” formulas for T1(n), . . . , T4(n))

n (Running Time)/n T1(n) T2(n) T3(n) T4(n) 10 20 30 40 50 20 40 60 80 100

So, which algorithm is best? Computers solve problems with big inputs. We care about large n. Compare runtimes asymptotically in the input size n. That is n → ∞.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 12 / 16 Linear Functions Θ(n) →

slide-74
SLIDE 74

Summary of Maximum Substring Sum Algorithms

Runtimes T1(n) = 2 + 31

6 n + 7 2n2 + 1 3n3

T2(n) = 2 + 6n + 3n2

3n(log2 n + 1) − 9 ≤ T3(n) ≤ 12n(log2 n + 3) − 9

T4(n) = 5 + 10n

(“simple” formulas for T1(n), . . . , T4(n))

n (Running Time)/n T1(n) T2(n) T3(n) T4(n) 10 20 30 40 50 20 40 60 80 100

So, which algorithm is best? Computers solve problems with big inputs. We care about large n. Compare runtimes asymptotically in the input size n. That is n → ∞. Ignore additive and multiplicative constants (minutia). We care about growth rate.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 12 / 16 Linear Functions Θ(n) →

slide-75
SLIDE 75

Summary of Maximum Substring Sum Algorithms

Runtimes T1(n) = 2 + 31

6 n + 7 2n2 + 1 3n3

T2(n) = 2 + 6n + 3n2

3n(log2 n + 1) − 9 ≤ T3(n) ≤ 12n(log2 n + 3) − 9

T4(n) = 5 + 10n

(“simple” formulas for T1(n), . . . , T4(n))

n (Running Time)/n T1(n) T2(n) T3(n) T4(n) 10 20 30 40 50 20 40 60 80 100

So, which algorithm is best? Computers solve problems with big inputs. We care about large n. Compare runtimes asymptotically in the input size n. That is n → ∞. Ignore additive and multiplicative constants (minutia). We care about growth rate. Algorithm 4 is linear in n, T4(n)

n

→ constant.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 12 / 16 Linear Functions Θ(n) →

slide-76
SLIDE 76

Asymptotically Linear Functions: Θ(n), big-Theta-of-n

T ∈ Θ(n), if there are positive constants c, C for which c · n ≤ T(n) ≤ C · n.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 13 / 16 General Asymptotics →

slide-77
SLIDE 77

Asymptotically Linear Functions: Θ(n), big-Theta-of-n

T ∈ Θ(n), if there are positive constants c, C for which c · n ≤ T(n) ≤ C · n. T(n) n

− →

n→∞

                      

∞ T ∈ ω(n), “T > n”;

constant>0

T ∈ Θ(n), “T = n”; T ∈ o(n), “T < n”.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 13 / 16 General Asymptotics →

slide-78
SLIDE 78

Asymptotically Linear Functions: Θ(n), big-Theta-of-n

T ∈ Θ(n), if there are positive constants c, C for which c · n ≤ T(n) ≤ C · n. T(n) n

− →

n→∞

                      

∞ T ∈ ω(n), “T > n”;

constant>0

T ∈ Θ(n), “T = n”; T ∈ o(n), “T < n”.

Linear means in Θ(n):

2n + 7, 2n + 15√n, 109n + 3, 3n + log n, 2log2 n+4.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 13 / 16 General Asymptotics →

slide-79
SLIDE 79

Asymptotically Linear Functions: Θ(n), big-Theta-of-n

T ∈ Θ(n), if there are positive constants c, C for which c · n ≤ T(n) ≤ C · n. T(n) n

− →

n→∞

                      

∞ T ∈ ω(n), “T > n”;

constant>0

T ∈ Θ(n), “T = n”; T ∈ o(n), “T < n”.

Linear means in Θ(n):

2n + 7, 2n + 15√n, 109n + 3, 3n + log n, 2log2 n+4.

Not linear, not in Θ(n):

10−9n2, 109√n + 15, n1.0001, n0.9999, n log n, n log n, 2n.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 13 / 16 General Asymptotics →

slide-80
SLIDE 80

Asymptotically Linear Functions: Θ(n), big-Theta-of-n

T ∈ Θ(n), if there are positive constants c, C for which c · n ≤ T(n) ≤ C · n. T(n) n

− →

n→∞

                      

∞ T ∈ ω(n), “T > n”;

constant>0

T ∈ Θ(n), “T = n”; T ∈ o(n), “T < n”.

Linear means in Θ(n):

2n + 7, 2n + 15√n, 109n + 3, 3n + log n, 2log2 n+4.

Not linear, not in Θ(n):

10−9n2, 109√n + 15, n1.0001, n0.9999, n log n, n log n, 2n.

Other runtimes from practice:

log linear loglinear quadratic cubic superpolynomial exponential factorial BAD

Θ(log n) Θ(n) Θ(n log n) Θ(n2) Θ(n3) Θ(nlog n) Θ(2n) Θ(n!) Θ(nn)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 13 / 16 General Asymptotics →

slide-81
SLIDE 81

General Asymptotics: Θ(f), big-Theta-of-f

T(n) f(n) −

n→∞

                      

∞ T ∈ ω(f), “T < f”;

constant>0

T ∈ Θ(f), “T = f”; T ∈ o(f), “T < f”.

n − → T(n)/f(n) Θ(f) ω(f)

  • (f)

T ∈ o(f) T ∈ Θ(f) T ∈ ω(f)

“T < f” “T = f” “T > f”

cf(n) ≤ T(n) ≤ Cf(n) Examples and Practice. (See also Exercise 9.6)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 14 / 16 The Integration Method →

slide-82
SLIDE 82

General Asymptotics: Θ(f), big-Theta-of-f

T(n) f(n) −

n→∞

                      

∞ T ∈ ω(f), “T < f”;

constant>0

T ∈ Θ(f), “T = f”; T ∈ o(f), “T < f”.

n − → T(n)/f(n) Θ(f) ω(f)

  • (f)

T ∈ o(f) T ∈ Θ(f) T ∈ ω(f)

“T < f” “T ≤ f” “T = f” “T ≥ f” “T > f”

cf(n) ≤ T(n) ≤ Cf(n) Examples and Practice. (See also Exercise 9.6)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 14 / 16 The Integration Method →

slide-83
SLIDE 83

General Asymptotics: Θ(f), big-Theta-of-f

T(n) f(n) −

n→∞

                      

∞ T ∈ ω(f), “T < f”;

constant>0

T ∈ Θ(f), “T = f”; T ∈ o(f), “T < f”.

n − → T(n)/f(n) Θ(f) ω(f)

  • (f)

T ∈ o(f) T ∈ O(f) T ∈ Θ(f) T ∈ Ω(f) T ∈ ω(f)

“T < f” “T ≤ f” “T = f” “T ≥ f” “T > f”

cf(n) ≤ T(n) ≤ Cf(n) Examples and Practice. (See also Exercise 9.6)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 14 / 16 The Integration Method →

slide-84
SLIDE 84

General Asymptotics: Θ(f), big-Theta-of-f

T(n) f(n) −

n→∞

                      

∞ T ∈ ω(f), “T < f”;

constant>0

T ∈ Θ(f), “T = f”; T ∈ o(f), “T < f”.

n − → T(n)/f(n) Θ(f) ω(f)

  • (f)

T ∈ o(f) T ∈ O(f) T ∈ Θ(f) T ∈ Ω(f) T ∈ ω(f)

“T < f” “T ≤ f” “T = f” “T ≥ f” “T > f”

T(n) ≤ Cf(n) cf(n) ≤ T(n) ≤ Cf(n) cf(n) ≤ T(n) Examples and Practice. (See also Exercise 9.6)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 14 / 16 The Integration Method →

slide-85
SLIDE 85

General Asymptotics: Θ(f), big-Theta-of-f

T(n) f(n) −

n→∞

                      

∞ T ∈ ω(f), “T < f”;

constant>0

T ∈ Θ(f), “T = f”; T ∈ o(f), “T < f”.

n − → T(n)/f(n) Θ(f) ω(f)

  • (f)

T ∈ o(f) T ∈ O(f) T ∈ Θ(f) T ∈ Ω(f) T ∈ ω(f)

“T < f” “T ≤ f” “T = f” “T ≥ f” “T > f”

T(n) ≤ Cf(n) cf(n) ≤ T(n) ≤ Cf(n) cf(n) ≤ T(n) Examples and Practice. (See also Exercise 9.6)

For polynomials, growth rate is the highest order.

2n2 n2 + n√n n2 + log256 n n2 + n1.99 log256 n Θ(n2) Θ(n2) Θ(n2) Θ(n2)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 14 / 16 The Integration Method →

slide-86
SLIDE 86

General Asymptotics: Θ(f), big-Theta-of-f

T(n) f(n) −

n→∞

                      

∞ T ∈ ω(f), “T < f”;

constant>0

T ∈ Θ(f), “T = f”; T ∈ o(f), “T < f”.

n − → T(n)/f(n) Θ(f) ω(f)

  • (f)

T ∈ o(f) T ∈ O(f) T ∈ Θ(f) T ∈ Ω(f) T ∈ ω(f)

“T < f” “T ≤ f” “T = f” “T ≥ f” “T > f”

T(n) ≤ Cf(n) cf(n) ≤ T(n) ≤ Cf(n) cf(n) ≤ T(n) Examples and Practice. (See also Exercise 9.6)

For polynomials, growth rate is the highest order. For nested sums, growth rate is number of nestings plus order of summand.

2n2 n2 + n√n n2 + log256 n n2 + n1.99 log256 n

n

  • i=1 i

n

  • i=1

i

  • j=1 1

n

  • i=1

i

  • j=1 ij

Θ(n2) Θ(n2) Θ(n2) Θ(n2) Θ(n2) Θ(n2) Θ(n4)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 14 / 16 The Integration Method →

slide-87
SLIDE 87

The Integration Method

n

0 dx f(x)

f(1) f(2) f(3) · · · f(n)

f(x)

1 2 3 · · · n n+1

  • Theorem. (Integration Bound)

For a monotonically increasing function f,

Creator: Malik Magdon-Ismail Sums And Asymptotics: 15 / 16 Integration For Asymptotic Behavior →

slide-88
SLIDE 88

The Integration Method

n

0 dx f(x)

f(1) f(2) f(3) · · · f(n)

f(x)

1 2 3 · · · n n+1

  • Theorem. (Integration Bound)

For a monotonically increasing function f,

n

m−1 dx f(x) ≤ n

  • i=m f(i)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 15 / 16 Integration For Asymptotic Behavior →

slide-89
SLIDE 89

The Integration Method

n

0 dx f(x)

n+1

1

dx f(x)

f(1) f(2) f(3) · · · f(n)

f(x)

1 2 3 · · · n n+1 f(1) f(2) f(3) · · · f(n) 1 2 3 · · · n n+1

  • Theorem. (Integration Bound)

For a monotonically increasing function f,

n

m−1 dx f(x) ≤ n

  • i=m f(i)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 15 / 16 Integration For Asymptotic Behavior →

slide-90
SLIDE 90

The Integration Method

n

0 dx f(x)

n+1

1

dx f(x)

f(1) f(2) f(3) · · · f(n)

f(x)

1 2 3 · · · n n+1 f(1) f(2) f(3) · · · f(n) 1 2 3 · · · n n+1

  • Theorem. (Integration Bound)

For a monotonically increasing function f,

n

m−1 dx f(x) ≤ n

  • i=m f(i) ≤

n+1

m

dx f(x).

Creator: Malik Magdon-Ismail Sums And Asymptotics: 15 / 16 Integration For Asymptotic Behavior →

slide-91
SLIDE 91

The Integration Method

n

0 dx f(x)

n+1

1

dx f(x)

f(1) f(2) f(3) · · · f(n)

f(x)

1 2 3 · · · n n+1 f(1) f(2) f(3) · · · f(n) 1 2 3 · · · n n+1

  • Theorem. (Integration Bound)

For a monotonically increasing function f,

n

m−1 dx f(x) ≤ n

  • i=m f(i) ≤

n+1

m

dx f(x).

(If f is monotonically decreasing, the inequalities are reversed.)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 15 / 16 Integration For Asymptotic Behavior →

slide-92
SLIDE 92

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-93
SLIDE 93

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-94
SLIDE 94

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-95
SLIDE 95

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-96
SLIDE 96

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-97
SLIDE 97

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-98
SLIDE 98

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-99
SLIDE 99

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-100
SLIDE 100

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-101
SLIDE 101

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-102
SLIDE 102

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-103
SLIDE 103

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-104
SLIDE 104

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n ∈ Θ(n ln n).

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-105
SLIDE 105

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n ∈ Θ(n ln n).

Analyzing a Recurrence

T1 = 1; Tn = Tn−1 + n√n − ln n.

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-106
SLIDE 106

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n ∈ Θ(n ln n).

Analyzing a Recurrence

T1 = 1; Tn = Tn−1 + n√n − ln n.

First unfold the recurrence

Tn = Tn−1 + n√n − ln n Tn−1 = Tn−2 + (n − 1)√n − 1 − ln(n − 1) . . . T3 = T2 + 3 √ 3 − ln 3 T2 =

✒ 1

T1 + 2 √ 2 − ln 2

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-107
SLIDE 107

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n ∈ Θ(n ln n).

Analyzing a Recurrence

T1 = 1; Tn = Tn−1 + n√n − ln n.

First unfold the recurrence

Tn = Tn−1 + n√n − ln n Tn−1 = Tn−2 + (n − 1)√n − 1 − ln(n − 1) . . . T3 = T2 + 3 √ 3 − ln 3 T2 =

✒ 1

T1 + 2 √ 2 − ln 2 + Tn = 1 + 2 √ 2 + · · · + n√n − (ln 2 + ln 3 + · · · + ln n)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-108
SLIDE 108

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n ∈ Θ(n ln n).

Analyzing a Recurrence

T1 = 1; Tn = Tn−1 + n√n − ln n.

First unfold the recurrence

Tn = Tn−1 + n√n − ln n Tn−1 = Tn−2 + (n − 1)√n − 1 − ln(n − 1) . . . T3 = T2 + 3 √ 3 − ln 3 T2 =

✒ 1

T1 + 2 √ 2 − ln 2 + Tn = 1 + 2 √ 2 + · · · + n√n − (ln 2 + ln 3 + · · · + ln n) =

n

  • i=1

i √ i −

n

  • i=1

ln i

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-109
SLIDE 109

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n ∈ Θ(n ln n).

Analyzing a Recurrence

T1 = 1; Tn = Tn−1 + n√n − ln n.

First unfold the recurrence

Tn = Tn−1 + n√n − ln n Tn−1 = Tn−2 + (n − 1)√n − 1 − ln(n − 1) . . . T3 = T2 + 3 √ 3 − ln 3 T2 =

✒ 1

T1 + 2 √ 2 − ln 2 + Tn = 1 + 2 √ 2 + · · · + n√n − (ln 2 + ln 3 + · · · + ln n) =

n

  • i=1

i √ i −

n

  • i=1

ln i

T(n) =

n

  • i=1 i

√ i

  • Θ(n5/2)

n

  • i=1 ln i
  • ln n!∈Θ(n ln n)

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16

slide-110
SLIDE 110

Integration For Quickly Getting Asymptotic Behavior

Integer Powers. Set f(x) = xk:

n

  • i=1 ik ≈

n

0 dx xk = nk+1

k + 1 ∈ Θ(nk+1).

Harmonic Numbers. Set f(x) = 1/x (monotonically decreasing):

n+1

1

dx 1

x

  • ln(n+1)

≤ Hn =

n

  • i=1

1 i ≤ 1 +

n

1 dx 1 x

  • 1+ln n

.

Stirling’s Approximation for ln n!. Set f(x) = ln x:

ln n! =

n

  • i=1 ln i

n+1

1

dx ln x = (n + 1) ln(n + 1) − n ∈ Θ(n ln n).

Analyzing a Recurrence

T1 = 1; Tn = Tn−1 + n√n − ln n.

First unfold the recurrence

Tn = Tn−1 + n√n − ln n Tn−1 = Tn−2 + (n − 1)√n − 1 − ln(n − 1) . . . T3 = T2 + 3 √ 3 − ln 3 T2 =

✒ 1

T1 + 2 √ 2 − ln 2 + Tn = 1 + 2 √ 2 + · · · + n√n − (ln 2 + ln 3 + · · · + ln n) =

n

  • i=1

i √ i −

n

  • i=1

ln i

T(n) =

n

  • i=1 i

√ i

  • Θ(n5/2)

n

  • i=1 ln i
  • ln n!∈Θ(n ln n)

T(n) ∈ Θ(n5/2).

Creator: Malik Magdon-Ismail Sums And Asymptotics: 16 / 16