Introduction to Algorithms - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Algorithms

Description:

: Introduction to Algorithms (Cormen, Leiserson, Rivest). ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 18
Provided by: visel
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Algorithms


1
???? ??????????
  • ??? ?????
  • Introduction to Algorithms
  • (Cormen, Leiserson, Rivest).
  • ???? ????? ?????? ???? ?????? (??? ?????)
  • ???? ??? ????
  • ???? ? 10-12
  • ? 12-1
  • ??? ???? ? 1-2
  • ???????
  • ?? ?????????
  • ??? ?? ????
  • ????? ????

2
?????? ?????
  • ????? ???? ?? ???????.
  • ???? ????, ????? ??????
  • ???? ???? 90 ???? 12 ???????.
  • ??? WEB ?? ????? ?????, ???????, ???????.
  • ????? ???? ???? ?? ???? ??????!

3
???? ?????
  • ??? ?' (4-5 ??????)
  • ?????????? ?? ?????
  • ????? ????? ??????
  • ??????? ????? ?????
  • ????? ????????
  • ??? ? (5-4 ??????)
  • ????? ????? ?????? ??????????
  • ????
  • ????? ??? ???? (????)
  • ????? ?????
  • ?????????? ???????
  • ?????????? ??????

4
???? ????? (????)
  • ?????????? ????????
  • ?????????? ?? ?????? ??????
  • ?????????? ??????????
  • ?????????? ????????
  • ????? ???????
  • ??? ?' (5-4 ??????)
  • ?????? ??????
  • ????? ??? ???????? ?????.

5
?????????
  • ????????? ???? ?? ???????
  • ???? ????? ????? ?????? ????? ?????????
  • ???
  • ??????? ????? ??? ????? ?????
  • ????????? ???? ????? ?? ???????

6
???? ????? ?????????
  • ???? ?????
  • ?????????
  • ???-??? (????)
  • ???????
  • ??? ???????
  • ????? ?????
  • ???? ????
  • ????? ?? ??????
  • ???????
  • ????? ???????? ????
  • ????? ???????

7
????
  • ?? N ??????
  • ??? ??? ??? ??????, ?? ????? ????? ??? ?????.
    (?? ?????? ????? ??? ????)
  • ??? ????? ?? ?? ???????, ?? ??? ????? ????? ??
    ??????.
  • ?????

1
3
4
2
8
?????
  • ???? ?? ????? ???? (N-1) ??????? ????????.
  • ??? ???? ?????? ?? ?????? ?-N.

??
9
????? Merge-Sort
  • Sort(A,i,j)
  • Ai..Aj ????? ?? ??? ?????
  • if iltj then
  • m lt-- (ij)/2
  • sort(A,i,m)
  • sort(A,m1,j)
  • merge(A,i,m,j)
  • Merge(A,i,m,j)
  • Am1..j, Ai..m ???? ? ??????? ???, ?????
    ?????? Ai..j ??? ??????

???? ??? Ai..m Am1..j
10
????
  • A1..n ??? ???? ??????
  • ??? ??? ?????? ????? ?????? 10000000 (?? ????
    ????)

11
?????
  • Sort A1N
  • for j1N
  • find 1000000-Aj in A
  • (FIND ????? ?? ????? ?????? ????? ?????.)

12
????? ??? ????
  • ????? ???? ???????? A
  • TA(n)
  • ???? ?? ???? ??????? ????? A ?? ???? ????? ?????
    ????? n
  • (?? ????? ??? ????)
  • ????? ????
  • f, g N --gt N
  • ???? ?
  • f O(g)
  • ?? ???? ???? C ?? ???? n
  • (f ???? ???? ?? ???? ?-g)

13
????? ?????? ???????
  • ?????
  • ??? C ?? ???? n
  • f(n) lt Cg(n)
  • ??? D ?? ???? n
  • h(n) lt Dg(n)
  • ???? ECD, ????? ??? n
  • (fh)(n)f(n)h(n) lt
  • lt Cg(n)Dg(n)Eg(n)
  • ???? ??
  • fO(g) hO(g)
  • ???
  • fhO(g)
  • ?????
  • (fh)(n) f(n) h(n)

14
?????????
  • ????? ???????
  • ??????? ???????
  • ??? ???? ????? ?????
  • ???? ?????
  • ??? ??????"
  • ???????
  • ???? ??? ??????? (????)
  • ????? ????? ?????
  • ?? ???? ??????
  • ???? ??? ????/???
  • ???? ??? ???

15
????? ??? ????
  • Proc1(A1..n)
  • s lt-- 0
  • for i 1 .. n do
  • for j (i 1) .. n do
  • if Ai lt Aj
  • s lt-- s 1

16
????? ??? ????
  • Proc2(A1..n)
  • i lt-- 1 j lt-- 1 s lt-- 0
  • repeat
  • if Ai lt Aj
  • s lt-- s 1
  • if jn
  • ji 1 i lt-- i1
  • else
  • j lt-- j1
  • until ij gt 2n
  • Proc1(A1..n)
  • s lt-- 0
  • for i 1 .. n do
  • for j (i 1) .. n do
  • if Ai lt Aj
  • s lt-- s 1

17
Merge-Sort -- ??? ????
  • TMerge(n) O(n)
  • TSort(n) 2TSort(n/2) O(n)
  • TSort(1) O(1)
  • ????
  • Tsort(n) O(n log n)
Write a Comment
User Comments (0)
About PowerShow.com