325: paapt d - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

325: paapt d

Description:

A. Levitin, 'Introduction to the Design and Analysis of Algorithms', 2nd Ed. ?e?????? a?? at?? ... Find the prime factors of m. Identify all common factors ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 24
Provided by: christosp1
Category:
Tags: algorithms | paapt

less

Transcript and Presenter's Notes

Title: 325: paapt d


1
??? 325 ?pa?a??pt???? ????d??
  • ??d?s??? ???st?? ?a?a???t??

2
?pa?a??pt???? ????d??
  • ?? e??a? a??????µ??
  • ???????µ?? e??a? µ?a se??? ap? saf? (unambiguous)
    ß?µata ta ?p??a ?????? ??a p??ß??µa.

3
???????µ??
  • Saf? ß?µata (e?t????)
  • ??s?d?? ?? e?d?? ?a? e???? t?? ded?µ???? e?s?d??
    ?a p??pe? ep?s?? ?a e??a? saf?
  • ? a??????µ?? µp??e? ?a pe????afe? µe p??????
    t??p??? (d?a??aµµat???, ?e?d?-??d??a?)
  • ?p??e? ?a ?p?????? p????? a??????µ?? p?? ??????
    ??a p??ß??µa
  • ?p??e? ?a ????? p??? d?af??et??? ap?d?s?
    (ta??t?ta ep???s?? ? apa?t?se?? µ??µ??)

4
??? 325 ?pa?a??pt???? ????d??.
  • A. Levitin, Introduction to the Design and
    Analysis of Algorithms, 2nd Ed.
  • ?e?????? µa??µat??
  • ?p?p??s?ete? ?????f???e?
  • www.eng.ucy.ac.cy/christos/courses/ECE325

5
  • ?e? ?p???e? (?a? de? µp??e? ?a ?p???e?) ??a?
    ???????µ?? p?? ?a ???e? ??a ta p??ß??µata!

6
?a??de??µa
  • ??e?te t? µ???st? ????? d?a???t? (greatest common
    divisor) µeta?? d?? a???a??? a???µ?? m, n.
  • ??s?d??
  • ???d?? z // µ???st?? ?????? d?a???t??

7
???????µ?? 1
  • Find the prime factors of m
  • Identify all common factors that appear in both
  • Compute the product of the common factors
  • ?a??de??µa

8
???????µ?? 1
  • Find the prime factors of m
  • Find the prime factors of n
  • Identify all common factors that appear in both
  • Compute the product of the common factors

9
???????µ?? 2
  • t minm, n
  • If m mod t 0 Goto 3, Else Goto to 4
  • If n mod t 0 return t
  • Set t t-1 and Goto 2.
  • ?a??de??µa m60, n 24

10
???????µ?? 3 (???????µ?? t?? ????e?d?)
  • gcd(m, n)
  • If n0 Return m
  • gcd(n,m mod n)
  • ?a??de??µa m60, n 24

11
????? ?p???s?? ???ß??µ?t?? µe ???????µ????
?e??d???
  • ?ata???s? t?? p??ß??µat??
  • ???a? ad??at? ?a ??sete ??a p??ß??µa e?? de? t?
    ?ata??ßete!
  • ???pe? ?a ???ste? epa???ß?? t? s????? ???? t??
    p??a??? e?s?d??.
  • ???at?t?te? t?? µ??a??? p?? ?a ??se? t?
    p??ß??µa
  • ??? ?a ???e? st? ???? t?te de? µp??e? ?a ??e?
    pe??ss?te?a ap? µe????? de??de? ß?µata.
  • ??a? ?p?????st?? de? ??e? ?pe??? ?p?????st???
    ??a??t?ta!

12
????? ?p???s?? ???ß??µ?t?? µe ???????µ????
?e??d???
  • ????ß?? ??s? ? ??s? ?at? p??s????s? (exact or
    approximate algorithm)
  • ?e???? p??ß??µata de? µp????? ?a ?????? a???ß??
  • ??a a???ß?? ??s? µp??e? ?a s??ep??eta? te??st??
    ?p?????st??? f??t? se a?t??es? µe µ?a
    p??se???st??? ??s? ? ?p??a µp??e? ?a e??a?
    ?p?????st??? p??? p?? ap?d?t???
  • ? s??d?asµ?? p??se???st???? ??se?? µp??e? ?a µa?
    d?se? t?? a???ß? ??s?

13
????? ?p???s?? ???ß??µ?t?? µe ???????µ????
?e??d???
  • ???te??p???s?
  • S?ed?asµ?? t?? a??????µ?? ep???s?? t??
    p??ß??µat??
  • ?e????af? t?? a??????µ??
  • ?????s? t?? ????t?ta? t?? a??????µ??
  • G?a ??a ta p??a?? ded?µ??a e?s?d??
  • ?a??µat??? epa???? (mathematical induction)

14
????? ?p???s?? ???ß??µ?t?? µe ???????µ????
?e??d???
  • ?????s? t?? ap?d?s?? t?? a??????µ??
  • ?pa?t?se?? µ??µ??
  • ?p??t?ta (simplicity)
  • ?p??? a??????µ?? ?ata?????ta? ?a? ???p?????ta?
    e?????te?a
  • ??a? a??????µ?? p?? ?aµß??e? ?p??? ??e? t??
    p??a??? e?s?d??? µp??e? ?a e??a? p??? p??
    p???p????? ap? ??p???? ???? ? ?p???? µp??e? ?a
    a???e? se????a ta ?p??a ?a µ?? eµfa?????ta? p???
    s????.
  • ???p???s?

15
??p?? ???ß??µ?t??
  • ???ß??µata ?a????µ?s?? (sorting)
  • ???ß??µata ??a??t?s?? (searching)
  • ?pe?e??as?a se???? s?µß???? (string processing)
  • ???ß??µata se ???f??? (graph problems)
  • S??d?ast??? ???ß??µata (combinatorial problems)
  • Ge?µet???? ???ß??µata (geometric problems)
  • ????µ?t??? ???ß??µata (numerical problems)

16
???ß??µata ?a????µ?s?? (sorting)
  • ?ed?µ???? e??? s?????? ap? st???e?a ta????µ?ste
    ta se µ?a se??? µe ß?s? ??p??? ??e?d? (key).
  • ?? ??e?d? ?a p??pe? ?a ??a??p??e? µ?a s??s? p??
    ?a ep?t??pe? t?? ta????µ?s?
  • G?at? e??a? s?µa?t??? ?a d?at????µe ta????µ?µ??e?
    ??ste?
  • ?p???e? ??a? µe????? a???µ?? ap? a??????µ???
    ta????µ?s??. G?at?
  • ?d??t?te?
  • ??sta?e?? (stable) a??????µ?? ta????µ?s??
  • ???????µ?? p?? de? ??e?????ta? ep?p??s?et? µ??µ?

17
???ß??µata ??a??t?s?? (searching)
  • ??a??t?s? e??? ? pe??ss?t???? st???e???
    (a?t??e?µ????) se ??a s????? s?µf??a µe t? ??e?d?
    a?a??t?s??.
  • ?????? f???? ta p??ß??µata a?a??t?s?? µp??e? ?a
    s??d?ast??? µe d?? ???a p??ß??µata
  • ???ß??µata ße?t?st?p???s?? µp????? ?a d?at?p?????
    sa? p??ß??µata a?a??t?s??
  • ??e?te ta st???e?a t?? s?????? ??a ta ?p??a µ?a
    s????t?s? pa???e? t? ß??t?st? t?µ? (e????st? ?
    µ???st?).

18
???ß??µata se ???f??? (graph problems)
  • G(V,E)
  • ???s?µ?p?????ta? e????? ??a t? µ??te??p???s?
    p????? p??ß??µ?t??
  • ???ß??µata ße?t?st?p???s?? µp????? ?a d?at?p?????
    sa? p??ß??µata se ???f??? s??d???ta? ta t??a µe
    ??p??? ??st?? ? ß???? (cost or weight).

19
S??d?ast??? ???ß??µata (combinatorial problems)
  • ???ß??µata p?? s?????? ??t??? t?? e??es? t??
    s??d?asµ?? a?t??e?µ???? p?? ??a??p????? ??p?????
    pe?????sµ??? (constraints) ?a? p?? ße?t?st?p?????
    ??p??a s????t?s? ??st???.
  • ?a??de??µa
  • ??a? ßa?????? p??pe? ?a pe??se? ??a ????, µ?a
    ?ats??a ?a? ??a µa????? ap? t?? µ?a ???? t??
    p?taµ?? st?? ???? ???s?µ?p????ta? µ?a ß???a st??
    ?p??a µp??e? ?a ????se? µ??? ??a a?t??e?µe??!
  • ????? ?? pe?????sµ?? ?a? p?? µp??e? ?a t?
    ?ataf??e?

20
Ge?µet???? ???ß??µata (geometric problems)
  • ???????µ??? ??s? ?e?µet????? p??ß??µ?t??
  • ?a p??ß??µata a?t? eµfa?????ta? s???? se d??f??e?
    efa?µ???? ??µp?t????, ??af????, t?µ???af?a? ??p.
  • ?a?ade??µata
  • ?e????? t?? p?? ???t???? s?µe??? (closest-pair
    problem)
  • Convex hull problem (p??? t? µ????te?? µ???? e???
    f???t? p?? ?a eµpe????e?e? ??a s????? ap? s?µe?a)

21
????µ?t??? ???ß??µata (Numerical problems)
  • S?µpe???aµß????? ??a µe???? e???? p??ß??µ?t??
  • ????? ap? a?t? ta p??ß??µata ?????ta? (se
    ?p?????st??) ?at? p??s????s? af?? ??a?
    ?p?????st?? ??e? pe?????sµ??? a???ße?a e?? ??
    ????t?? a???µ?? ??e?????ta? ?pe??? a???µ? ??f???.
  • ? a???µ?t??? p??s????s? ???? t?? st???????p???s??
    a???µ?? µp??e? ?a d?µ??????se? p??? µe???a
    sf??µata ?d?a?te?a se epa?a??pt????? (iterative)
    ? a?ad??µ????? (recursive) a??????µ???!

22
???ß??µata ?p?f?se?? ?a? ?e?t?st?p???s??
  • ???ß??µata ?p?f?se?? (Decision Problems)
  • ???ß??µata t?? t?p?? a?t?? e??a? d?at?p?µ??a µe
    t?t??? t??p? ?ste ? ap??t?s? pa???e? t? µ??f?
    (?a?/???, yes/no, 1/0).
  • ?a??de??µa
  • ?e?t??????? ???ß??µata (function problems)
  • ???ß??µata sta ?p??a ? ap??t?s? de? e??a? t??
    µ??f?? ?a?/???
  • ?a??de??µa
  • ???ß??µata ße?t?st?p???s??

23
???ß??µata ?p?f?se?? ?a? ?e?t?st?p???s??
  • ???ß??µata ße?t?st?p???s??
  • ?p???ste p?? X ap?te?e? t? s????? ???? t??
    p??a??? pe??pt?se?? (st??µ??t?p??) e???
    p??ß??µat??.
  • C(X)?? e??a? ?p?s????? t?? ? µe ??a ta st???e?a
    p?? ??a??p????? ????? t??? pe?????sµ??? t??
    p??ß??µat??.
Write a Comment
User Comments (0)
About PowerShow.com