Chapter 1 Introduction Mathematics Review - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 1 Introduction Mathematics Review

Description:

* Modular Arithmetic We say that A is congruent to B modulo N Written as (mod N) If N divides ... Chapter 1 Introduction Mathematics Review Last modified by: – PowerPoint PPT presentation

Number of Views:122
Avg rating:3.0/5.0
Slides: 19
Provided by: fsu115
Learn more at: http://www.cs.fsu.edu
Category:

less

Transcript and Presenter's Notes

Title: Chapter 1 Introduction Mathematics Review


1
Chapter 1IntroductionMathematics Review
Sections 1.1, 1.2
2
Outline
  • Why does program execution time for large inputs
    matter?
  • Basic mathematical background

3
Selection Problem
  • Find the kth largest number from a group of N
    numbers
  • How would you solve this?
  • Algorithm 1
  • Sort the N numbers and pick the kth one.
  • Easy to implement, but
  • Sorting requires many comparisons
  • Much work comparing elements having no chance to
    be at position K
  • To sort N elements, need N log2(N)
    comparisons/swaps in general
  • An unsorted data set with 10,000,000 elements and
    1,000 swaps/sec will take around 2 hours

4
Selection Problem (Contd)
  • Algorithm 2 (Better)
  • Sort first K elements in the array.
  • Then insert elements (K1) to N, discarding the
    smallest element each time.
  • Then pick the kth element.
  • What if N10 million and K5,000,000?
  • How long do you think this would take?
  • Both algorithms are impractical.
  • A better algorithm can solve this in a second!

5
Mathematics Review
  • Exponents
  • Logarithms
  • Series
  • Modular arithmetic
  • Proof techniques

6
Exponents
7
Logarithms
  • All logarithms are to the base 2, unless
    otherwise specified
  • Definition 1.1
  • XA B if and only if logxB A

8
Properties of logarithms
  • Theorem 1.1 (base-change)
  • A, B, C gt
    0, A ? 1
  • Proof Let X logCB, Y logCA, and Z logAB
  • Then CX B, CY A, and AZ B
  • Implies B CX (CY)Z CYZ
  • Hence X YZ
  • And Z X/Y

9
Logarithms (contd.)
  • Theorem 1.2
  • log(AB) log A log B A, B gt 0
  • Proof (Assume base 2)
  • Let X log A, Y log B, and Z log AB
  • Hence 2X A, 2Y B, and 2Z AB
  • Combining the above 2Z AB 2X2Y 2(XY)
  • Implies X Y Z

10
Logarithms (contd.)
  • More results
  • log(A/B) log A log B
  • log(AB) B log A
  • log X lt X for all X gt 0
  • log 1 0
  • log2 2 1
  • log2 1024 10
  • log2 1,048,576 20

11
Geometric Series
  • If 0 lt A lt 1,
  • If N -gt , we have
  • How??

12
Arithmetic Series
  • How about 258(3k-1) ?

13
Modular Arithmetic
  • We say that A is congruent to B modulo N
  • Written as (mod N)
  • If N divides (A-B)
  • In other words, the remainder is the same if
    either A or B are divided by N
  • E.g.
  • (mod 10)
  • Similar to equality, if (mod N), then
  • (mod N), and
    (mod N)

14
Proof techniques
  • Two common proof techniques in data structure and
    algorithm analysis (and in CS, in general)
  • Proof by induction
  • Proof by contradiction
  • Another common technique
  • Proof a statement false with a counterexample

15
Proof by Induction
  • Given a theorem
  • First prove a base case
  • Show the theorem is true for some small
    degenerate values
  • Next assume an inductive hypothesis
  • Assume the theorem is true for all cases up to
    some limit k
  • Then prove that the theorem holds for the next
    value (k1)

16
Proof by Induction - example
  • Fibonacci Series
  • F0 1, F1 1, Fi F(i-1) F(i-2), for igt1
  • Show that
  • Fi lt (5/3)i,for igt0
  • Base case
  • F1 1 lt 5/3
  • F2 2 lt (5/3)225/9
  • Inductive Hypothesis
  • Assuming Fi lt (5/3) i , i 1, 2, ..., k

17
Proof by Induction - example (contd.)
  • Now prove that Fk1 lt (5/3)k1
  • From definition of Fibonacci Sequence
  • Fk1 Fk Fk-1
  • Using inductive hypothesis

Fk1 lt (5/3) k (5/3) k-1 (5/3) k1 3/5
(3/5)2 (5/3) k1 24/25 lt (5/3)
k1
18
Other types of proofs
  • Disprove with a counter-example
  • The statement is false in the
    Fibonacci series
  • Proof F11 144 gt 112 121
  • Proof by contradiction
  • Initially assume that the theorem is false
  • Then show that some known property would be false
    as well.
  • Example There is an infinite number of prime
    numbers
  • Proof
  • Assume the theorem is false (so there are only
    finite prime)
  • Let P1, P2, ..., Pk be all the primes in
    increasing order.
  • Let N P1?P2 ? ??? ?Pk 1,N is gt Pk , so it
    is not a prime
  • But it is also not divisible by any of the listed
    primes, contradicting the factorization of
    integers into primes.
  • We reach a contradiction
Write a Comment
User Comments (0)
About PowerShow.com