1 / 11

MA/CSSE 473 Day 05

MA/CSSE 473 Day 05. More induction Factors and Primes Recursive division algorithm. MA/CSSE 473 Day 05. HW 2 due tonight, 3 is due Monday Student Questions Two more induction examples Asymptotic Analysis example: summation Continue Algorithm Overview/Review

morag
Download Presentation

MA/CSSE 473 Day 05

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MA/CSSE 473 Day 05 More induction Factors and Primes Recursive division algorithm

  2. MA/CSSE 473 Day 05 • HW 2 due tonight, 3 is due Monday • Student Questions • Two more induction examples • Asymptotic Analysis example: summation • Continue Algorithm Overview/Review • Integer Primality Testing and Factoring • Modular Arithmetic intro

  3. Another Induction Example Tiling with Trominoes • We saw that a 2n2n checkerboard can be tiled with dominoes. • What about trominoes? • Clearly, we can't tile an entire board! • Definition: A deficient rectangular grid of squares is one that has one square missing. • It's easy to see that we can tile a 22 deficient rectangle! (We can rotate the tromino) Note: HW 4 will mainly be about tiling with trominoes. Q1

  4. Trominoes Continued • What about a 4 x 4 deficient rectangle? • Can we tile this? • Fun with Tromino tiling:http://www3.amherst.edu/~nstarr/trom/puzzle-8by8/

  5. Trominoes Continued • Prove by induction that we can tile any 2n2n deficient rectangle with trominoes • Base case: n=1 Done • Assume that we can do it for n=k • Show that we can do it for n=k+1 • Assume WLOG that the missing square is in the lower right quadrant of the rectangle • If it is somewhere else, we could simply rotate the board. • Can we place one tromino in a way that allows us to use the induction assumption?

  6. Another Induction ExampleExtended Binary Tree (EBT) • An Extended Binary tree is either • an external node, or • an (internal) root node and two EBTs TL and TR. • We draw internal nodes as circles and external nodes as squares. • Generic picture and detailed picture. • This is simply an alternative way of viewing binary trees, in which we view the null pointers as “places” where a search can end or an element can be inserted.

  7. A property of EBTs • Property P(N): For any N>=0, any EBT with N internal nodes has _______ external nodes. • Proof by strong induction, based on the recursive definition. • A notation for this problem: IN(T), EN(T) • Note that, like some other simple examples, this one can be done without induction. • But the purpose of this exercise is practice with strong induction, especially on binary trees. • What is the crux of any induction proof? • Finding a way to relate the properties for larger values (in this case larger trees) to the property for smaller values (smaller trees). Do the proof now. Q2-3

  8. Asymptotic Analysis Example • Find a simple big-Theta expression (as a function of n) for the following sum • when 0 < c < 1 • when c = 1 • when c > 1 • f(n) = 1 + c + c2 + c3 + … + cn Q4

  9. FACTORING and PRIMALITY • Two important problems • FACTORING: Given a number N, express it as a product of its prime factors • PRIMALITY: Given a number N, determine whether it is prime • Conclusions • Factoring is hard • The best algorithms so far require time that is exponential in the number of bits of N • Primality testing is relatively easy • A strange disparity for these closely related problems • Exploited by cryptographic algorithms • More on these problems later Q5

  10. Recap: Arithmetic Run-times • For operations on two n-bit numbers: • Addition: Ѳ(n) • Multiplication: • Standard algorithm: Ѳ(n2) • "Gauss-enhanced": Ѳ(n1.59), but with a lot of overhead. • Division (We won't ponder it in detail, but see next slide): Ѳ(n2)

  11. Algorithm for Integer Division Let's work through divide(19, 4). Analysis? Q6

More Related