Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
×

# アルゴリズムイントロダクション 第2章

5,391 views

Published on

アルゴリズムイントロダクション 第2章の勉強会資料

http://tniky1.com/study/

Published in: Technology, Business
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

### アルゴリズムイントロダクション 第2章

1. 1. 2010 CS
3. 3. 2010 CS   -  -    -    - Θ Copyright© 2010 tniky1 All rights reserved. Page 3
5. 5. 2010 CS j 1 1 2 3 4 5 6 2 5 4 6 1 3 i length[A] procedure Insertion-Sort(A) for j ← 2 to length[A] do key ← A[j] i←j−1 while i > 0 and A[i] > key do A[i+1] ← A[i] i←i−1 A[i+1] ← key Copyright© 2010 tniky1 All rights reserved. Page 5
7. 7. 2010 CS     -  A[1...j-1] → j 2 5 4 6 1 3 A[1...j-1] Copyright© 2010 tniky1 All rights reserved. Page 7
8. 8. 2010 CS   -  -  -  -  -  -  ( ) Copyright© 2010 tniky1 All rights reserved. Page 8
9. 9. 2010 CS j 2 5 4 6 1 3 A[1...j-1] for j ← 2 to length[A] J=2 do key ← A[j] A[1] A[1..j-1] i←j−1 while i > 0 and A[i] > key A[j] A[j-1],A[j-2]... do A[i+1] ← A[i] A[j] i←i−1 (A[1..j-1] ) A[i+1] ← key Copyright© 2010 tniky1 All rights reserved. Page 9
10. 10. 2010 CS j=n+1 1 2 3 4 5 6 A[1...j-1]=A[1..n] for j ← 2 to length[A] j=n+1 do key ← A[j] A[1..j-1]=A[1..n] ! i←j−1 while i > 0 and A[i] > key do A[i+1] ← A[i] i←i−1 A[i+1] ← key Copyright© 2010 tniky1 All rights reserved. Page 10
12. 12. 2010 CS   -  -  -  ( )   -  ( DB DB ) - Copyright© 2010 tniky1 All rights reserved. Page 12
13. 13. 2010 CS j 1 2 3 4 5 6 2 5 4 6 1 3 i n for j ← 2 to length[A] n do key ← A[j] n-1 i←j−1 n-1 while i > 0 and A[i] > key do A[i+1] ← A[i] i←i−1 tj A[i+1] ← key n-1 ( ) Copyright© 2010 tniky1 All rights reserved. Page 13
14. 14. 2010 CS for j ← 2 to length[A] C1 n do key ← A[j] C2 n-1 i←j−1 C3 n-1 while i > 0 and A[i] > key C4 do A[i+1] ← A[i] C5 i←i−1 C6 A[i+1] ← key C7 n-1 T(n) Copyright© 2010 tniky1 All rights reserved. Page 14
15. 15. 2010 CS T(n) ( ) j 1 2 3 4 5 6 [ ] 5 6 4 3 2 1 i=0 i tj=i Copyright© 2010 tniky1 All rights reserved. Page 15
16. 16. 2010 CS   -  -    -  -  - Copyright© 2010 tniky1 All rights reserved. Page 16