p es at - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

p es at

Description:

?e??s? ?at? ??a p?s?st? (decrease by a constant factor) ... PERT (Program Evaluation and Review) ??s? e DFS. dfs(v) v.visited= true; for w= 1 to wn ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 30
Provided by: christosp1
Category:
Tags: pert

less

Transcript and Presenter's Notes

Title: p es at


1
???????µ?? ??p?? ?e??s?? ???ß??µat??
2
?e??????
  • ???????µ?? ??p?? ?e??s?? ???ß??µat?? (Decrease
    and Conquer)
  • ?e??s? ?at? µ?a sta?e?? (decrease by a constant)
  • ?e??s? ?at? ??a p?s?st? (decrease by a constant
    factor)
  • ?e??s? ?at? µetaß??t? µ??e??? (variable-size-decre
    ase)

3
???????µ?? ?e??s?? ???ß??µat?? ?at? µ?a Sta?e??
  • Ge???? ?e??d?????a
  • ??t? ?a ??s??µe t? p?? d?s???? p??ß??µa µe??????
    n, ?????µe t? p?? e????? p??ß??µa µe?????? n-m.
  • S?????? t? m1.
  • ?p? t? ??s? t?? µ????te??? p??ß??µat?? µp????µe
    ?a ß???µe t? ??s? t?? p??ß??µat?? µe?????? n.
  • ?p?? ?a??de??µa ?p?????ste t? s????t?s? an

4
???ß??µata ?a????µ?s??
  • ??s?d?? ??sta A0,,n-1
  • ???d?? ?a????µ?µ??? ??sta A0,,n-1
  • InsertionSort
  • ?as??? ?d?a

5
???ß??µata ?a????µ?s??
  • ??s?d?? ??sta A0,,n-1
  • ???d?? ?a????µ?µ??? ??sta A0,,n-1

insertionsort(A0,,n-1) for i0 to n-1 new
Ai ji-1 while jgt0 and Ajgt
new Aj1 Aj j j-1 Aj1 new
6
?p?d?s? InsertionSort()
insertionsort(A0,,n-1) for i0 to n-1 new
Ai ji-1 while jgt0 and Ajgt
new Aj1 Aj j j-1 Aj1 new
G?at? ?a ???s?µ?p???se? ??p???? t?
InsertionSort()
  • ?e???te?? ?e??pt?s?
  • ?a??te?? ?e??pt?s?

7
??e?e???s? G??f?? (Tree Traversal)
  • ?ed?µ???? e??? ???f??, p?? µp??e? ??p???? ?a
    ep?s?efte? ????? t??? ??µß??? t?? ???f??.
  • ??t? e??a? ??a p??ß??µa t? ?p??? pa???s???eta?
    s???? se ???f???.
  • ?p??e? ?a ?p?????? p????? ??se??. Ta µe?et?????
    d?? t??p?? p?? eµp?pt??? ??t? ap? t?? ?at?????a
    µe??s?? t?? p??ß??µat?? ?at? µ?a sta?e?? (??a).
  • ? ßas??? ?d?a e??a? ?t? t? p?? d?s???? p??ß??µa
    e?e?e???s?? ???f?? µe n ??µß??? sp??e? se ??a
    p??ß??µa ??a n-1 ??µß??? af?? p??ta ep?s?eft??µe
    t?? aµ?s?? ep?µe?? ??µß?.
  • ?e t? ?d?? s?ept??? ?a µp????se ??p???? ?a
    ?atat??e? t??? a??????µ??? a?t??? ??t? ap? t??
    ?at?????a t?? greedy a??????µ??.

8
Depth-First Search (DFS) ?a? Breadth-First Search
(BFS)
  • ? Ge???? p??s????s? t?? DFS e??a? af?? ep?s?efte?
    ??a ??µß?, ?a ???e? ??a t?? aµ?s?? ep?µe??
    ?e?t????? ??µß?.
  • ???? ??????a ? a??????µ?? ap?µa????eta? ap? ??a
    ??µß?, p??? ep?s?efte? ????? t??? ?e?t??e?.
  • ???p??e?ta? a?ad??µ??? ? µe st??ßa.
  • ? ?e???? p??s????s? t?? BFS e??a? ?a ep?s?efte?
    ????? t??? ?e?t??e? e??? ??µß?? p???
    ap?µa?????e?.
  • ???p??e?te µe ????
  • ?? d?? a??????µ?? ????? t?? ?d?a ap?d?s?
    d?af????? st?? se??? µe t?? ?p??a ?a ep?s?eft???
    t??? ??µß???.

9
DFS
10
DFS ?a??de??µa
dfs(v) v.visited true for w 1 to wn if
w.visited false dfs(w)
11
BFS
BFS(GltV,Egt) for all v in V if v.visited
false bfs(v)
bfs(v) v.visited true while Q not
empty for w 1 to wn if w.visited
false w.visited true Q.enqueue(w) Q.
dequeue(Q.head)
12
DFS ?a??de??µa
bfs(v) v.visited true while Q not
empty for w 1 to wn if w.visited
false w.visited true Q.enqueue(w) Q.
dequeue(Q.head)
13
??p??????? ?a????µ?s?
  • ???ß??µa ?ed?µ???? e??? ?ate?????µe??? ???f??,
    ?p???e? t??p?? ?a ta????µ?s??µe ????? t???
    ??µß??? ?ts? ?ste e?? ?p???e? a?µ? ap? t?? ??µß?
    u st?? v, st?? ta????µ?µ??? se???, ? u ?a
    eµfa???eta? p??? ap? t?? v
  • ?a?ade??µata

14
??p??????? ?a????µ?s?
  • Te???µa ?? p??ß??µa t?? t?p???????? ta????µ?s??
    ??e? ??s? e?? ?a? µ???? a? ? ?ate?????µe???
    ???f?? p?? pe?????fe? t? p??ß??µa de? ??e?
    ??????? (?ate?????µe??? ??????? ???f?? directed
    acyclic graph (dag)).
  • ?fa?µ???? t?p???????? ta????µ?s??
  • ???apa?t??µe?a µa??µata
  • ?????p????aµµat?sµ?? (scheduling)
  • ??e??as??? se ?p?????st?
  • ???as??? ??a t?? s?µp????s? µe????? ?????.
  • ??e?d??e?µ??e? ??se??
  • Critical Path Method (CPM)
  • PERT (Program Evaluation and Review)

15
??s? µe DFS
dfs(v) v.visited true for w 1 to wn if
w.visited false dfs(w)
?
E
C
F
D
B
16
??s? µe DFS
dfs(v) v.visited true for w 1 to wn if
w.visited false dfs(w)
?
E
C
F
D
B
17
??p??????? ?a????µ?s? ??s? ßas?sµ??? se µe??s?
?at? ??a
  • ?as??? ?d?a
  • Se ???e ß?µa ??????µe ??a ????? se ??a ???f? ?
    ?p???? e??a? ?at? ??a µ????te??? ap? ?t? ?
    p??????µe???.
  • ?p? t?? µe?a??te?? ???f?, afa????µe ??a ??µß?
    st?? ?p??? de? ?ata???e? p??? t?? ?aµ?? a?µ?
    ?a??? ?a? ??e? t?? a?µ?? p?? ?e?????? ap? t? e?
    ???? ??µß?.
  • ?a??de??µa

18
??µ??????a ???? t?? p??a??? ?p?s?????? ?a?
permutations
  • ???ß??µa S??µat?ste ??a ta p??a?? ?p?s????a
    (power set) p?? µp????µe ?a d?µ??????s??µe ap?
    ??a s????? n st???e???.
  • ???ß??µa S??µat?ste ??e? t?? p??a??? d?at??e??
    (permutations) t?? ?p??e? µp????µe ?a
    d?µ??????s??µe ap? ??a s????? n st???e???.
  • ?p? t? f?s? t??? ta p??ß??µata a?t? de? µp?????
    ?a ????? ap?d?t??? ??s?! G?at?
  • ?? d??f???? s??d?asµ?? ?a? d?at??e??
    d?µ????????ta? se???a?? ?p?ta? p????? f????
    e??a? ep???µ?t? ?a µ?? ?p?????? µe???e? e?a??a???
    ap? t? ??a ?p?s????? st? ep?µe?? ? t? µ?a d??ta??
    st?? ep?µe??.

19
Power Set
?????sµa n st???e??? ?p?? t? ???e st???e?? µp??e?
?a p??e? t? t?µ? 0 (e?? t? st???e?? de?
pe???aµß??eta? st? ?p?s?????) ?a? 1 (e??
pe???aµß??eta?)
  • ???a?? ?p?s????a ??a n5
  • ??sa p??a?? ?p?s????a

20
Permutations
?????sµa n st???e??? ?p?? t? ???e st???e?? µp??e?
?a p??e? t? t?µ? e??? ap? ta st???e?a t?? s??????.
  • ???a?? permutations ??a n5
  • ??sa p??a?? ?p?s????a

21
Permutations ???????µ?? ßas?sµ???? se µe??s?
?at? ??a
  • ?p???ste p?? ?????µe p?? ?a d?µ??????s??µe ??a ta
    permutations ??a n-1, p?? µp????µe ?a
    d?µ??????s??µe ta permutations ??a n
  • ?p?? t?p??et??µe t? ??? st???e?? µeta?? ???? t??
    st???e??? ap? t?? ?p?????se? d?at??e??
  • ? a??????µ?? Johnson-Trotter d?µ?????e? ??a ta
    permutations ????? ?a p??pe? ?a d?µ??????se? ta
    n-1, n-2, 1, permutations ?a? se ???e ß?µa
    a??????? µ??? 2 st???e?a ??s?.

22
???????µ?? µe??s?? t?? p??ß??µat?? ?at? ??a
p?s?st?
  • Ge???? ?e??d?????a
  • ??t? ?a ??s??µe t? p?? d?s???? p??ß??µa µe??????
    n, ?????µe t? p?? e????? p??ß??µa µe?????? n/m.
  • S?????? t? m2.
  • ?p? t? ??s? t?? µ????te??? p??ß??µat?? µp????µe
    ?a ß???µe t? ??s? t?? p??ß??µat?? µe?????? n.
  • ???? ap?d?t???? a??????µ?? (a?a??t?s? se d?ad???
    d??t??)!
  • ?p?? ?a??de??µa ?p?????ste t? s????t?s? an

23
???p??? ??µ?sµa
  • ?p???ste ?t? ??ete n ??µ?sµata e? t?? ?p??? t?
    ??a ???p???. ???e ??µ?sµa ?????e? w ??aµµ???a
    e?? t? ???p??? ?????e? qltw ??aµµ???a.
  • ?p???ste p?? ??ete st? d???es? sa? µ?a ???a???.
  • ??? µp??e?te ?a e?t?p?sete t? ???p??? ??µ?sµa
    ?????ta? ????te?a ap? n ????sµata
  • ??sa ????sµata ??e???este

24
???p??? ??µ?sµa
  • ??sa ????sµata ??e???este

findCoin(C1,,n) if(n l) return C fake
found ffloor(n/2) P1C1,,f
P2Cf1,,2f P3Cn-C2f X weight(P1,
P2) if X1 return findCoin(P1) P1 weights
more if X0 return P3 P1 P2 weigh the
same if X-1 return findCoin(P2) P2 weights
more
25
????ap?as?asµ?? ??e?a??? se ????? (Hardware)
  • ??? µp??e? ??p???? ?a p???ap?as??se? d??
    a???a???? a???µ??? m, n
  • ?p???ste ?t? t? n e??a? ??t??, t?te
  • ?p???ste ?t? t? n e??a? pe??tt?, t?te
  • ??p???? µp??e? ?a ???p???se? ??a p???ap?as?ast?
    µe µ??? a????sµata ?a? µetat?p?se??!

26
?p???s? µ? ??aµµ???? e??s?se?? µ?a? µetaß??t??
  • ??? µp??e?te ?a ß?e?te t? ??s? t?? p?? ??t? µ?
    ??aµµ???? e??s?s?? st? d??st?µa a,b
  • ?p???ste p?? µa? e?d?af????? µ??? ta p?? ??t?
    se????a
  • ??e?te ??a a??????µ? p?? ?a p??se????e? t? ??s?

27
Bisection Method Divide-and-Conquer
  • ???a? ????? ? a??????µ??
  • ??te te?µat??e?

28
Bisection Method Divide-and-Conquer
solve(f(),a,b,e,iter,N) x(ab)/2 if (b-a)lte
or itergtN return x fxf(x) if fx0 return x
if fxf(a)gt0 return solve(f,x,b,e,iter1,N) r
eturn solve(f,a,x,e,iter1,N)
  • ??? µetaß???eta? t? µ???st? d??at? sf??µa t??
    a??????µ?? ap? epa?????? se epa??????.

29
False Position Method Divide-and-Conquer
  • ???s?s? t?? e??e?a? p?? pe??? ap? ta s?µe?a
    (a,fa), (b,fb)
  • ?p???f?a ??s?
  • St? s????e?a e??????µe t? t?µ? t?? s????t?s?? st?
    s?µe?? x ?a? s??e?????µe a?????a t?? a?a??t?s?.
  • ? a??????µ?? a?t?? eµp?pte? st?? ?at?????a
    µe??s?? t?? p??ß??µat?? a??? ?at? µetaß??t?
    µ??e??? (variable size decrease).
  • ?p??e?te ?a s?efte?te a?t?st???? t??p? µe t??
    ?p??? ?a µetaß??ete t? a??????µ? a?a??t?s?? se
    d?ad??? d??t?a (binary search)
Write a Comment
User Comments (0)
About PowerShow.com