permuting upper and lower bounds
play

Permuting Upper and Lower bounds [Aggarwal, Vitter, 88] Page 1 - PowerPoint PPT Presentation

Permuting Upper and Lower bounds [Aggarwal, Vitter, 88] Page 1 Upper Bound Assume instance is specified by each element knowing its final position: 3 2 4 1 a c b d a c d b Algorithm Internal Cost I/O Cost 1) Place each element


  1. Permuting Upper and Lower bounds [Aggarwal, Vitter, 88] Page 1

  2. Upper Bound Assume instance is specified by each element knowing its final position: 3 2 4 1 a c b d a c d b Algorithm Internal Cost I/O Cost 1) Place each element directly Θ( N ) Θ( N ) 2) Sort on final position Θ( N log N ) Θ( N/B log M/B ( N/B )) Page 2

  3. Upper Bound Internally, 1) always best. Externally, 2) best when 1 /B log M/B ( N/B ) ≤ 1 . Note: This is almost always the case practice. Example: B = 10 3 , M = 10 6 , N = 10 30 ⇓ 1 /B log M/B ( N/B ) = 9 / 10 3 << 1 External Permuting: O (min { N/B log M/B ( N/B ) , N } ) = O (min { sort( N ) , N } ) Page 3

  4. Lower Bound Model Model of combined memory (RAM + disk): RAM Disk · · · • Elements are indivisible: May be moved, copied, destroyed, but newer broken up in parts. • Assume M ≥ 2 B . • May assume I/Os are block-aligned, and that at start [end], input [output] is in lowest contiguous positions on disk. Page 4

  5. Lower Bound We may assume that elements are only moved , not copied or destroyed. Reason : For any sequence of I/Os performing a permutation, exactly one copy of each element exists at end. Change all I/Os performed to only deal with these copies. Result: same number of I/Os, same permutation at end, but now I/Os only move elements. Consequence : Memory always contains a permutation of the input Recall, memory means combined memory (RAM + disk), seen as one array. Page 5

  6. Lower Bound In analysis, keep a set S t of permutations. Maintain the following invariants: 1. S t contains all permutations of elements in memory possible to reach with t I/Os. 2. S t is closed under permutations of the elements in RAM, and under permutation of the elements inside each touched block on disk. For an I/O, let X be an upper bound on the increase of | S t | : | S t +1 | ≤ X · | S t | . Page 6

  7. Bounds on Value of X Type of I/O Read untouched block Read touched block Write � M � M B N � � X B ! BN BN B B B For t I/Os, there are at most 3 t sequences of choices of the three types. For each sequence, there are at most N/B untouched reads. Hence, from | S 0 | = 1 and | S t +1 | ≤ X · | S t | we get � t �� M � | S t | ≤ 3 t ( B !) N/B BN B To be able to reach every possible permutation, we need N ! ≤ | S t | . Thus, � t � � M � ( B !) N/B N ! ≤ 3 BN B is necessary to reach all permutations. Page 7

  8. Lower Bound Computation � t � � M � ( B !) N/B ≥ N ! 3 BN B � M � t (log + 3 log N ) + ( N/B ) log( B !) ≥ log( N !) B t (3 B log( M/B ) + 3 log N ) + N log B ≥ N (log N − log 2 ( e )) t ≥ N (log N − log 2 ( e ) − log B ) 3 B log( M/B ) + 3 log N N log( N/B ) t = Ω( B log( M/B ) + log N ) a) log( x !) ≥ x (log x − log 2 ( e )) b) log( x !) ≤ x log x Using Lemma: � x � c) log ≤ 3 y log( x/y ) when x ≥ 2 y y d) log(3 BN ) ≤ 3 log( N ) when 3 ≤ N , B ≤ N Page 8

  9. Lower Bound N log( N/B ) Ω( B log( M/B ) + log N ) = Ω(min { N log( N/B ) B log( M/B ) , N log( N/B ) } ) log N = Ω(min { Z 1 , Z 2 } ) Note 1: Z 1 = sort( N ) Note 2: Z 2 < Z 1 ⇔ B log( M/B ) < log N ⇒ B < log N ⇒ Z 2 = N log( N/B ) = N (log N − log B ) = Θ( N ) log N log N Note 3: Z 2 ≤ N always By Note 2 and 3, it is OK to substitute N for Z 2 inside min . Page 9

  10. The I/O Complexity of Permuting We have proven: Θ(min { sort( N ) , N } ) Page 10

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend