1 / 11

報告者: 張書豪

GCD The Design and Analysis of Computer Algorithms 8.8 Greatest common divisors and Euclid’s algorithm. 報告者: 張書豪. Outline. Half GCD Example. HGCD Algorithm. procedure HGCD(a 0 ,a 1 ) : If DEG(a 1 ) ≦DEG(a 0 )/2 then else begin

lilian
Download Presentation

報告者: 張書豪

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. GCDThe Design and Analysis of Computer Algorithms 8.8 Greatest common divisors and Euclid’s algorithm 報告者:張書豪

  2. Outline • Half GCD • Example

  3. HGCD Algorithm procedure HGCD(a0,a1): If DEG(a1) ≦DEG(a0)/2 then else begin let a0=b0xm+c0, where m= and DEG(c0) <m; let a1=b1xm+c1,where DEG(c1)<m; R←HGCD(b0,b1);

  4. f ← d modulo e; end

  5. Example HGCD(a0,a1) a0(x)=x5+x4+x3+x2+x+1 a1(x)=x4-2x3+3x2-x-7 由a0=b0xm+c0與a1=b1xm+c1,可得到 b0= x3+x2+x+1, c0=x+1, b1=x2-2x+3, c1=-x-7, HGCD(x3+x2+x+1, x2-2x+3) DEG(b1) >DEG(b0)/2

  6. 再做HGCD(b0,b1) a0(x)= x3+x2+x+1, a1(x)=x2-2x+3, 由a0=(x2+x+1)x1+1, a1=(x-2)x1+3,可得到 b0= x2+x+1, c0=1, b1=x-2, c1=3, 此時DEG(b1) =DEG(b0)/2 R←HGCD(b0,b1)

  7. 可得d= x3+x2+x+1,e= x2-2x+3,f=d mod e=4x-8 m/2=3/2下限為1,e=(x-2)x+3,f=4(x)-8, g0=x-2,g1=4x0,DEG(0)=DEG(1)/2的下限 S←HGCD(g0,g1)

  8. R←HGCD(b0,b1) d= x4-2x3+3x2-x-7 e= 4x3-7x2+11x+22 f ← d modulo e;

  9. e=(4x2-7x+11)x1+22,

  10. b0=4x3-7x2+11x+22, b1=-3/16x2-93/16x-45/8, DEG(2)>DEG(3)/2下限 →b0=(4x2-7x+11)x+22 b1=(-3/16x-93/16)x-45/8 DEG(1)=DEG(2)/2

More Related