balanced programming
play

Balanced Programming Group Static Shanghai Jiao Tong University - PowerPoint PPT Presentation

. . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Balanced Programming Group Static Shanghai Jiao Tong University December 27, 2016 Group Static . . . . . . . . .


  1. . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Balanced Programming Group Static Shanghai Jiao Tong University December 27, 2016 Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  2. . Another Example . . . . . . . . . Introduction Baby step giant step Meet in the middle . Thanks Overview 1 Introduction 2 Baby step giant step 3 Another Example 4 Meet in the middle Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  3. . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Features Kind of a useful designing idea. Easy implementation and good performance in practice. Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  4. . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Features Kind of a useful designing idea. Easy implementation and good performance in practice. Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  5. . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Balances Balanced in learning from each each other. Balanced in the problem-solving processes. Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  6. . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Balances Balanced in learning from each each other. Balanced in the problem-solving processes. Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  7. . Baby step giant step . . . . . . . . . . Introduction Another Example . Meet in the middle Thanks Available occiasion There are two algorithms, both of which have difgerent features, such as one can answer queries very quickly and the other cam handle modifjcation swiftly. There is an algorithm to solve the problems, but is quite complicated. Actually this algorithm is not the best choice in practice. The idea of balanced programming might be used to produced a suitable algorithm. Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  8. . Baby step giant step . . . . . . . . . . Introduction Another Example . Meet in the middle Thanks Available occiasion There are two algorithms, both of which have difgerent features, such as one can answer queries very quickly and the other cam handle modifjcation swiftly. There is an algorithm to solve the problems, but is quite complicated. Actually this algorithm is not the best choice in practice. The idea of balanced programming might be used to produced a suitable algorithm. Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  9. . Another Example . . . . . . . . . Introduction Baby step giant step Meet in the middle . Thanks Overview 1 Introduction 2 Baby step giant step 3 Another Example 4 Meet in the middle Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  10. . . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Problem Find a smallest non-negative number x satisfying Group Static . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming A x ≡ B ( mod P ) which P is a prime, A , B ∈ [0 , P ) .

  11. . . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Naive Approach Group Static . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming According to Fermat Theorem, when A , P are coprime, we have: A P ≡ A ( mod P ) the only special case is A = 0 , and in this case, B must be zero. For A ̸ = 0 , we can just iterate x from 0 to P − 1 to check if A x ≡ B ( mod P ) . The complexity is O ( P ) .

  12. . . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Yet Another Naive Algorithm In order to fjnd B , we just need to query B in this Hash-Table, Group Static . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming We mapped A x → x , x ∈ [0 , P ) by using a Hash-Table. which only takes O (1) time. Precalculating this Hash-Table costs O ( P ) time, and the total complexity of which is O ( P + 1) = O ( P ) .

  13. . . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Balanced Programming Group Static . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming First we choose a number S ∈ [1 , P − 1] . We mapped A x → x , x ∈ [0 , S ) by using a Hash-Table. Calculate A − S by using Fast Exponentiation. In this step, we needs S + log P operations.

  14. . . . . . . . . . . . . . . . Introduction Baby step giant step Another Example Meet in the middle Thanks Balanced Programming S . Group Static . . . . . . . . . . . . . . . . . . . . Balanced Programming . . . . . A x ≡ B ( mod P ) x can be represented as i × S + j , we can do such transforming: A i × S + j ≡ B ⇔ A j ≡ B × ( A − S ) i ( mod P ) which j ∈ [0 , S ) , and i < P S to check if B × ( A − S ) i is in We can just iterate i from 0 to P Hash-Table. In the worst occasion, we need to iterate P S times.

  15. . . . . . . . . . . . . Introduction . Baby step giant step Another Example Meet in the middle Thanks Total complexity evaluation As you can see, the total operations we need to do are S we want to choose S optimally to get the best total complexity. P , the total operations are: Group Static . . . . . . . . . . . . . . . . . . . . . Balanced Programming . . . . . . S + log P + P √ when S = √ √ S + log P + P S = 2 P + log P = O ( P ) √ thus we get an O ( P ) algorithm by choosing S optimally.

  16. . Another Example . . . . . . . . . Introduction Baby step giant step Meet in the middle . Thanks Overview 1 Introduction 2 Baby step giant step 3 Another Example 4 Meet in the middle Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  17. . Introduction . . . . . . . . . . Baby step giant step . Another Example Meet in the middle Thanks Another Problem an undirected graph add x to u query neighbors’ sum O m n Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  18. . Introduction . . . . . . . . . . Baby step giant step . Another Example Meet in the middle Thanks Another Problem an undirected graph add x to u query neighbors’ sum O m n Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  19. . Introduction . . . . . . . . . . Baby step giant step . Another Example Meet in the middle Thanks Another Problem an undirected graph add x to u query neighbors’ sum O m n Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  20. . Introduction . . . . . . . . . . Baby step giant step . Another Example Meet in the middle Thanks Another Problem an undirected graph add x to u query neighbors’ sum O m n Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  21. . Introduction . . . . . . . . . . Baby step giant step . Another Example Meet in the middle Thanks Another Problem an undirected graph add x to u query neighbors’ sum O m n Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  22. . Introduction . . . . . . . . . . Baby step giant step . Another Example Meet in the middle Thanks Another Problem an undirected graph add x to u query neighbors’ sum O m n Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming

  23. . . . . . . . . . . . . Introduction . Baby step giant step Another Example Meet in the middle Thanks Another Problem an undirected graph add x to u query neighbors’ sum Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming O ( m ) = n

  24. . . . . . . . . . . . . Introduction . Baby step giant step Another Example Meet in the middle Thanks Naive Approach 1 O n space O time for add O n time for query Group Static . . . . . . . . . . . . . . . . . . . . . . . . . . . Balanced Programming store the value v [ x ]

Recommend


More recommend