×
Copy
Open
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Basic Sort Hiroki Kumamoto
Slide 2
Slide 2 text
Selection Sort • Ұ൪খ͍͞Λ୳͢ͱ͍͏ͷΛNճ܁Γฦ͢ • Ұ൪খ͍͞ͷΛa[i]ʹ࣋ͬͯ͘Δ • 1/2N^2 ͷൺֱ • (N-1) + (N-2)+ …. + 1 + 0 • Nճͷަ • O(N^2)
Slide 3
Slide 3 text
• Visualize demo • http://kumabook.github.io/playground/ index.html#selection-sort
Slide 4
Slide 4 text
Insertion sort • i-1൪·Ͱ͕ྻ͍ͯ͠Δͱͯ͠ɺi൪ͷཁૉ Λ0..i൪ͷதͰਖ਼͍͠Ґஔʹૠೖ͢Δ • best case: ྻࡁΈ: N -1 ͷൺֱ + 0ަ • worst case: ٯॱ: 1/2 N^2ͷൺֱ+ 1/2N^2ͷަ • O(N) ~ O(N^2)
Slide 5
Slide 5 text
• Visualize demo • http://kumabook.github.io/playground/ index.html#insertion-sort
Slide 6
Slide 6 text
Shell Sort • Insertion sort ٯॱʹฒΜͰ͍Δͱ͖ʹ͍ • → ͱͼͱͼͷinsertion sortԿճ͔ʹ͚ͯΔ • Best sequence of increments? • 1, 3, 7, 15, 31, 63 … Powers of two minus one. • 1, 4, 13, 40, 121, 364…3x + 1 • ฏۉɿO (N ^ 3/2)
Slide 7
Slide 7 text
Shell Sort • αΠζͷখ͍͞ྻʹରͯ͠༗ޮ • bzip2, /linux/kernel/groups.c • ίʔυͷfoot print ͕খ͍͞ • uClibc
Slide 8
Slide 8 text
• Visualize demo • http://kumabook.github.io/playground/ index.html#shell-sort
Slide 9
Slide 9 text
Reference • Coursera: Algorithms, Part 1 • https://www.coursera.org/course/algs4partI • http://algs4.cs.princeton.edu/home/