1 / 21

CS 473 -Algorithms I

CS 473 -Algorithms I. Lecture X Ackermann ’ s Function and Its Inverse. if i = 0. if i > 0 and lg (i-1) n > 0. if i > 0 and. or. lg (i-1) n is undefined. undefined. Repeated Exponentiation Function g( i ). i. That is. The parameter i gives the height of the stack of 2 ’ s

urvi
Download Presentation

CS 473 -Algorithms I

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. CS473-Algorithms I Lecture X Ackermann’s Function and Its Inverse Lecture X

  2. if i = 0 if i > 0 and lg(i-1)n > 0 if i > 0 and or lg(i-1)n is undefined undefined Repeated Exponentiation Functiong(i) i That is The parameter i gives the height of the stack of 2’s that make up the exponent 4 Repeated Logarithm Function lg(i)n The logarithm fn applied i time in succession starting with arg. n Lecture X

  3. Iterated Logarithm Function lg(*)n lg* n = min { i 0 : lg(i)n 1 } lg* 2 = 1 lg* 4 = lg*(22) = 2 lg* 16 = lg*(24) = 3 lg* 65536 = lg*(216) = 4 lg* (265536) = 5 • Since the number of atoms in the observable universe • 1080 << 265536 • We rarely encounter a value of n such that lg*n > 5 Lecture X

  4. P Iterated Logarithm Function Computation of lg* 65536 Therefore Lecture X

  5. n n n-1 where n n-1 n-2 n-2 n-3 Iterated Logarithm Function The lg*n fn is essentially the inverse of repeated exponentiation Lecture X

  6. . . . . . n-n=0 . Therefore n-i n Iterated Logarithm Function Lecture X

  7. Ackermann’s Function • Defined for integers i, j > 1 by • A(1, j) = 2j for j 1 • A(i, 1) = A(i – 1, 2) for i 2 • A(i, j) = A(i – 1, A(i, j - 1)) for i, j 2 j = 1 j = 2 j = 3 j = 4 23 24 22 21 i = 1 i = 2 i = 3 Lecture X

  8. Ackermann’s Function • Defined for integers i, j > 1 by • A(1, j) = 2j for j 1 • A(i, 1) = A(i – 1, 2) for i 2 • A(i, j) = A(i – 1, A(i, j - 1)) for i, j 2 j = 1 j = 2 j = 3 j = 4 23 24 22 21 i = 1 i = 2 i = 3 22 Lecture X

  9. Ackermann’s Function • Defined for integers i, j > 1 by • A(1, j) = 2j for j 1 • A(i, 1) = A(i – 1, 2) for i 2 • A(i, j) = A(i – 1, A(i, j - 1)) for i, j 2 j = 1 j = 2 j = 3 j = 4 23 24 22 21 i = 1 i = 2 22 2 22 i = 3 Lecture X

  10. Ackermann’s Function • Defined for integers i, j > 1 by • A(1, j) = 2j for j 1 • A(i, 1) = A(i – 1, 2) for i 2 • A(i, j) = A(i – 1, A(i, j - 1)) for i, j 2 j = 1 j = 2 j = 3 j = 4 23 24 22 21 i = 1 i = 2 22 2 2 22 22 i = 3 Lecture X

  11. Ackermann’s Function • Defined for integers i, j > 1 by • A(1, j) = 2j for j 1 • A(i, 1) = A(i – 1, 2) for i 2 • A(i, j) = A(i – 1, A(i, j - 1)) for i, j 2 j = 1 j = 2 j = 3 j = 4 23 24 22 21 i = 1 4 3 i = 2 22 16 2 2 22 22 2 i = 3 Lecture X

  12. . . Ackermann’s Function Second Row 1 2 3 4 . j Lecture X

  13. Ackermann’s Function Third Row 16 16 16 16 16 ∙ ∙ ∙ ∙ Lecture X

  14. ∙ 16 ∙ ∙ for j 2 j-1 of these 16 16 Ackermann’s Function Third Row • The first row, exponential in the column number j, is alreadyrapidly growing • The second row, consists of the widely spaced subset of columnsof the first row • The third row consists of even more widely spaced subset ofcolumns • , …, of the second row • which is even sparser subset of columns of the first row Lecture X

  15. Explosive Growth of Ackermann’s Function Column Spacings S1 S2 S3 S4 1 2 S1 S2 Row 3 4 5 Lecture X

  16. 16 16 Explosive Growth of Ackermann’s Function • The first row, exponential in the column number j, • is alreadyrapidly growing • The second row, consists of the widely spaced subset of columnsof the first row • The third row consists of even more widely spaced subset of columns • , …, of the second row • which is even sparser subset of columns of the first row Lecture X

  17. α(m, n) = min{ i 1 : A( i, ) > lg n } Explosive Growth of Ackermann’s Function IN GENERAL The spacing between successive columns of row i-1 appearing in row i increases dramatically with both the column number and the rownumberi Inverse of Ackermann’s Function • Proceed in the -th column of the matrix starting from the first row • Until you encounter a value > lg n • Return the row index of that value Lecture X

  18. Inverse of Ackermann’s Function • This fn is not the inverse of Ackermann’s fn in true math sense • It captures the spirit of the inverse in its growth • The mysterious lg n threshold appears in order to be able to prove the O(m α(m,n)) bound on the running time • Claim : for all practical purposes • since • Ackermann’s fn A(i, j) is strictly increasing with each argument • for all since Lecture X

  19. , so for all practical purposes Inverse of Ackermann’s Function In particular, But we also have A(4,1) = A(3,2) = Hence, A(4,1) >> 1080 = Estimated no. of atoms in the universe Thus, for all practical purposes 16 O(mlg*n) bound is only slightly weaker than O(m α(m,n)) bound Lecture X

  20. 1 1 2 ….. 1 2 3 4 5 . . . i2 A(i,c2) > A(i,c1) for all i where i1 A(i1,c1) = First value in col. c1 > lg n A(i2,c2) = First value in col. c2 > lg n An Important Property of Inverse Ackermann’s Function For a fixed value of n, as m increases the function α(m,n)is monotonically decreasing Proof :is monotonically increasing as m increases Thus, since n and hence lg n is fixed, the smallest row index i needed to bring above lg n is monotonicallydecreasing Lecture X

  21. An Important Property of Inverse Ackermann’sFunction • This property corresponds to our intuition about • disjoint set forests with pathcompression • We would expect the average FIND-PATHlength to decrease • due to pathcompression • If we perform m operations in time O(m α(m,n)) • then, the average time per operation is O(α(m,n)) • which is monotonically decreasing as m increases Lecture X

More Related